// 定义语句块
// 定义语句块下面对应的代码块
// 定义块

const path = require('path');
const staticImg = path.join(__dirname, 'static');

 function ArduinoUnoBlocks (Blockly) {
  var color_display = "#f59057";
  var color_do = '#FF0000';
  var base_color = '#179b73';
  var color_serial = '#FF4482';
  var color_sensor = '#28BFE6';
// 	    Blockly.Blocks.control_setup_loop = {
//     /**
//      * Block for if-else.
//      * @this Blockly.Block
//      */
//     init: function () {
//         this.jsonInit({
//             type: 'control_setup_loop',
//             message0: '',
//             message1: Blockly.Msg.BOOT_SETUP,
//             message2: '%1 ',
//             message3: 'loop',
//             message4: '%1',
//             args0: [],
//             args1: [],
//             args2: [
//                 {
//                     type: 'input_statement',
//                     name: 'SUBSTACK0'
//                 }
//             ],
//             args3: [],
//             args4: [
//                 {
//                     type: 'input_statement',
//                     name: 'SUBSTACK2'
//                 }
//             ],
//             category: Blockly.Categories.control,
//             // extensions: ['colours_arduino', 'scratch_extension']
//         });
//     }
// };

//lcd配置地址
Blockly.Blocks.ph20lcdinit = {
    init:function(){
    this.setColour(color_display);
    this.appendDummyInput("")
    .appendField(new Blockly.FieldImage(staticImg+"/39.LCD_1602.svg", 84, 42))
      .appendField(Blockly.Msg.PH_LCDINIT_ADDRESS)
      this.appendValueInput("lcdinits", Number)
    this.setPreviousStatement(true,null);
    this.setNextStatement(true,null);
    this.setTooltip('');
    }
  };
  
  //lcd光标
  Blockly.Blocks.ph20lcdposition = {
    init:function(){
    this.setColour(color_display);
    this.appendDummyInput("")
    .appendField(new Blockly.FieldImage(staticImg+"/39.LCD_1602.svg", 84, 42))
      .appendField(Blockly.Msg.PH_POSITION)
      this.appendValueInput("row", Number)
      .appendField(Blockly.Msg.PH_ROW)
      this.appendValueInput("col", Number)
      .appendField(Blockly.Msg.PH_COL)
    this.setPreviousStatement(true,null);
    this.setNextStatement(true,null);
    this.setTooltip('');
    }
  };
  //lcd打印
  Blockly.Blocks.ph20lcdprint = {
    init:function(){
    this.setColour(color_display);
    this.appendDummyInput("")
    .appendField(new Blockly.FieldImage(staticImg+"/39.LCD_1602.svg", 84, 42))
      .appendField(Blockly.Msg.PH_LCDPRINT)
      this.appendValueInput("lcdprints", String)
    this.setPreviousStatement(true,null);
    this.setNextStatement(true,null);
    this.setTooltip('');
    }
  };
  //lcd清屏
  Blockly.Blocks.ph20lcdclear = {
    init:function(){
    this.setColour(color_display);
    this.appendDummyInput("")
    .appendField(new Blockly.FieldImage(staticImg+"/39.LCD_1602.svg", 84, 42))
      .appendField(Blockly.Msg.PH_LCDCLEAR)
    this.setPreviousStatement(true,null);
    this.setNextStatement(true,null);
    this.setTooltip('');
    }
  };
//LED
Blockly.Blocks.ph_led = {
init:function(){
  this.setColour(color_display);
  this.appendDummyInput("")
  .appendField(new Blockly.FieldImage(staticImg+"/4.LED-Module.svg", 84, 42))
    .appendField(Blockly.Msg.PH_LED)
    .appendField(new Blockly.FieldDropdown([
      ['P1', "P1"],
      ['P2', "P2"],
      ['P3', "P3"],
      ['P4', "P4"],
      ['P9', "P9"],
      ['P10', "P10"],
      ['P11', "P11"],
      ['P12', "P12"],
    ]),"led")
    .appendField(new Blockly.FieldDropdown([
      [Blockly.Msg.PH_OPEN, "1"],
      [Blockly.Msg.PH_CLOSE, "0"],
    ]),"status")
    this.setPreviousStatement(true,null);
     this.setNextStatement(true,null);
  this.setTooltip('');
}
};

//激光发射传感器
Blockly.Blocks.ph_laser = {
  init:function(){
    this.setColour(color_do);
    this.appendDummyInput("")
    .appendField(new Blockly.FieldImage(staticImg+"/50-Laser Emission Module.svg", 84, 42))
      .appendField(Blockly.Msg.PH_LASER)
      .appendField(new Blockly.FieldDropdown([
        ['P1', "P1"],
        ['P2', "P2"],
        ['P3', "P3"],
        ['P4', "P4"],
        ['P9', "P9"],
        ['P10', "P10"],
        ['P11', "P11"],
        ['P12', "P12"],
      ]),"laser")
      .appendField(new Blockly.FieldDropdown([
        [Blockly.Msg.PH_OPEN, "1"],
        [Blockly.Msg.PH_CLOSE, "0"],
      ]),"laserStatus")
      this.setPreviousStatement(true,null);
       this.setNextStatement(true,null);
    this.setTooltip('');
  }
  };
//声音传感器
Blockly.Blocks.ph_vioce = {
init:function(){
  this.setColour(color_sensor);
  this.appendDummyInput("")
  .appendField(new Blockly.FieldImage(staticImg+"/29.Sound-Sensor.svg", 84, 42))
    .appendField(Blockly.Msg.PH_VIOCE)
    .appendField(new Blockly.FieldDropdown([
      ['P5', "P5"],
      ['P6', "P6"],
      ['P7', "P7"],
    ]),"phvioce")
      .appendField(Blockly.Msg.PH_READVIOCE);
this.appendDummyInput("") 
.appendField(new Blockly.FieldDropdown([
  [Blockly.Msg.PH_DIGITAL, "vioce.dpRead1()"],
  [Blockly.Msg.PH_ANALOG, "vioce.aRead2()"],
]),"vioceValue")
this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
    this.setOutput(true, 'Number');
  this.setTooltip('');
}
};
//光敏传感器
Blockly.Blocks.ph_light = {
init:function(){
  this.setColour(color_sensor);
  this.appendDummyInput("")
    .appendField(new Blockly.FieldImage(staticImg+"/8.Photosensitive Sensor.svg", 84, 42))
    .appendField(Blockly.Msg.PH_LIGHT)
    .appendField(new Blockly.FieldDropdown([
      ['P1', "P1"],
      ['P2', "P2"],
      ['P3', "P3"],
      ['P4', "P4"],
    ]),"phlight")
      .appendField(Blockly.Msg.PH_READLIGHT)
this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
    this.setOutput(true, 'Number');
  this.setTooltip('');
}
};
//触摸传感器
Blockly.Blocks.ph_touch = {
init:function(){
  this.setColour(base_color);
  this.appendDummyInput("")
   .appendField(new Blockly.FieldImage(staticImg+"/13.Touch-Module.svg", 84, 42))
    .appendField(Blockly.Msg.PH_TOUCH)
    .appendField(new Blockly.FieldDropdown([
      ['P1', "P1"],
      ['P2', "P2"],
      ['P3', "P3"],
      ['P4', "P4"],
      ['P9', "P9"],
      ['P10', "P10"],
      ['P11', "P11"],
      ['P12', "P12"],
    ]),"phtouch")
    .appendField(Blockly.Msg.PH_ISTOUCH)
      this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
  this.setOutput(true, 'Boolean');
  this.setTooltip('');
}
};
//按键传感器 ph_button
Blockly.Blocks.ph_button = {
init:function(){
  this.setColour(base_color);
  this.appendDummyInput("")
   .appendField(new Blockly.FieldImage(staticImg+"/14.Button - Module.svg", 84, 42))
    .appendField(Blockly.Msg.PH_BUTTONMODEL)
    .appendField(new Blockly.FieldDropdown([
      ['P1', "P1"],
      ['P2', "P2"],
      ['P3', "P3"],
      ['P4', "P4"],
      ['P9', "P9"],
      ['P10', "P10"],
      ['P11', "P11"],
      ['P12', "P12"],
    ]),"phbutton")
    .appendField(Blockly.Msg.PH_ISBUTTON)
    .appendField(new Blockly.FieldDropdown([
      [Blockly.Msg.PH_PRESS, "down"],
      [Blockly.Msg.PH_RELEASE, "loosen"],
      [Blockly.Msg.PH_LONGPRESS, "holdDown"],
    ]),"isButton")
      this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
  this.setOutput(true, 'Boolean');
  this.setTooltip('');
}
};
//热敏传感器
Blockly.Blocks.ph_thermosensitive = {
init:function(){
  this.setColour(color_sensor);
  this.appendDummyInput("")
  .appendField(new Blockly.FieldImage(staticImg+"/28.Thermal  sensor.svg", 84, 42))
    .appendField(Blockly.Msg.PH_THERMOSENSITIVE)
    .appendField(new Blockly.FieldDropdown([
      ['P1', "P1"],
      ['P2', "P2"],
      ['P3', "P3"],
      ['P4', "P4"],
    ]),"thermosensitive")
    .appendField(Blockly.Msg.PH_THERMOSENSITIVEREAD)
      .appendField(Blockly.Msg.PH_ANALOG)
this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
    this.setOutput(true, 'Number');
  this.setTooltip('');
}
};
//火焰传感器
Blockly.Blocks.ph_fire = {
init:function(){
    this.setColour(color_sensor);
    this.appendDummyInput("")
  .appendField(new Blockly.FieldImage(staticImg+"/35.Flame-Sensor.svg", 84, 42))
      .appendField(Blockly.Msg.PH_FIRE)
      .appendField(new Blockly.FieldDropdown([
        ['P5', "P5"],
        ['P6', "P6"],
        ['P7', "P7"],
      ]),"fire")
        .appendField(
          new Blockly.FieldDropdown([
            [Blockly.Msg.PH_ANALOG, "aRead2()"],
            [Blockly.Msg.PH_DIGITAL, "dpRead1()"],
          ]),"fireValue")
  this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
      this.setOutput(true, 'Number');
    this.setTooltip('');
  }
};

//避障传感器
Blockly.Blocks.ph_abstacle = {
  init:function(){
      this.setColour(color_sensor);
      this.appendDummyInput("")
    .appendField(new Blockly.FieldImage(staticImg+"/avoidance sensor.svg", 84, 42))
        .appendField(Blockly.Msg.PH_ABSTACLE)
        .appendField(new Blockly.FieldDropdown([
          ['P5', "P5"],
          ['P6', "P6"],
          ['P7', "P7"],
        ]),"abstaclePort")
          .appendField(
            new Blockly.FieldDropdown([
              [Blockly.Msg.PH_ANALOG, "aRead2()"],
              [Blockly.Msg.PH_DIGITAL, "dpRead1()"],
            ]),"abstacleValue")
    this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
        this.setOutput(true, 'Number');
      this.setTooltip('');
    }
  };

// //火焰传感器
// Blockly.Blocks.ph_isFire = {
//   init:function(){
//       this.setColour("#00B1AC");
//       this.appendDummyInput("")
//     .appendField(new Blockly.FieldImage(staticImg+"/35.Flame-Sensor.svg", 84, 42))
//         .appendField(Blockly.Msg.PH_FIRE)
//         .appendField(new Blockly.FieldDropdown([
//           ['P5', "P5"],
//           ['P6', "P6"],
//           ['P7', "P7"],
//         ]),"fire")
//           .appendField(
//             new Blockly.FieldDropdown([
//               [Blockly.Msg.PH_ANALOG, "aRead2()"],
//               [Blockly.Msg.PH_DIGITAL, "dRead2()"],
//             ]),"fireValue")
//     this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
//         this.setOutput(true, 'Number');
//       this.setTooltip('');
//     }
//   };
//土壤湿度传感器
Blockly.Blocks.ph_soil = {
init:function(){
  this.setColour(color_sensor);
  this.appendDummyInput("")
   .appendField(new Blockly.FieldImage(staticImg+"/26.Soit moisture Module.svg", 84, 42))
    .appendField(Blockly.Msg.PH_SOIL)
    .appendField(new Blockly.FieldDropdown([
      ['P1', "P1"],
      ['P2', "P2"],
      ['P3', "P3"],
      ['P4', "P4"],
    ]),"soil")
      .appendField(Blockly.Msg.PH_ANALOG)
this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
    this.setOutput(true, 'Number');
  this.setTooltip('');
}
};
//雨滴传感器
Blockly.Blocks.ph_rain = {
init:function(){
  this.setColour(color_sensor);
  this.appendDummyInput("")
   .appendField(new Blockly.FieldImage(staticImg+"/30.Water  droplets Sensor.svg", 84, 42))
    .appendField(Blockly.Msg.PH_RAIN)
    .appendField(new Blockly.FieldDropdown([
      ['P5', "P5"],
      ['P6', "P6"],
      ['P7', "P7"],
    ]),"rain")
    .appendField(new Blockly.FieldDropdown([
      [Blockly.Msg.PH_ANALOG, "aRead2()"],
      [Blockly.Msg.PH_DIGITAL, "dpRead1()"],
    ]),"rainValue")
this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
    this.setOutput(true, 'Number');
  this.setTooltip('');
}
};
//水深传感器
Blockly.Blocks.ph_waterdeep = {
init:function(){
  this.setColour(color_sensor);
  this.appendDummyInput("")
  .appendField(new Blockly.FieldImage(staticImg+"/25.Water  depth  Sensor.svg", 84, 42))
    .appendField(Blockly.Msg.PH_WATERDEEP)
    .appendField(new Blockly.FieldDropdown([
      ['P1', "P1"],
      ['P2', "P2"],
      ['P3', "P3"],
      ['P4', "P4"],
    ]),"waterdeep")
      .appendField(Blockly.Msg.PH_ANALOG)
this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
    this.setOutput(true, 'Number');
  this.setTooltip('');
}
};
//碰撞传感器
Blockly.Blocks.ph_knockswitch = {
init:function(){
  this.setColour(base_color);
  this.appendDummyInput("")
  .appendField(new Blockly.FieldImage(staticImg+"/2.Collision   Sensor.svg", 84, 42))
    .appendField(Blockly.Msg.PH_KNOCKSWITCH)
    .appendField(new Blockly.FieldDropdown([
      ['P1', "P1"],
      ['P2', "P2"],
      ['P3', "P3"], 
      ['P4', "P4"],
      ['P9', "P9"],
      ['P10', "P10"],
      ['P11', "P11"],
      ['P12', "P12"],
    ]),"knockswitch")
    .appendField(Blockly.Msg.PH_READKNOCKSWITCH)
      this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
  this.setOutput(true, 'Boolean');
  this.setTooltip('');
}
};
//dht11
Blockly.Blocks.ph_dht11 = {
init:function(){
  this.setColour(color_sensor);
  this.appendDummyInput("")
   .appendField(new Blockly.FieldImage(staticImg+"/12.Temperature   and humidity  sensor.svg", 84, 42))
    .appendField(Blockly.Msg.PH_DHT)
    .appendField(new Blockly.FieldDropdown([
      ['P1' , "P1" ],
      ['P2' , "P2" ],
      ['P3' , "P3" ],
      ['P4' , "P4" ],
      ['P9' , "P9" ],
      ['P10', "P10"],
      ['P11', "P11"],
      ['P12', "P12"]
    ]),"dht11")
      .appendField(Blockly.Msg.PH_READDHT)
      .appendField(new Blockly.FieldDropdown([
        [Blockly.Msg.PH_TEMPERATURE, "temperature"],
        [Blockly.Msg.PH_HUMIDITY, "humidity"],
      ]),"temhum")
this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
    this.setOutput(true, 'Number');
  this.setTooltip('');
}
};
//温度传感器初始化 ph_ds
Blockly.Blocks.ph_ds = {
init:function(){
  this.setColour(color_sensor);
  this.appendDummyInput("")
   .appendField(new Blockly.FieldImage(staticImg+"/3.DS18B20.svg", 84, 42))
    .appendField(Blockly.Msg.PH_DS)
    .appendField(new Blockly.FieldDropdown([
      ['P1' , "P1" ],
      ['P2' , "P2" ],
      ['P3' , "P3" ],
      ['P4' , "P4" ],
      ['P9' , "P9" ],
      ['P10', "P10"],
      ['P11', "P11"],
      ['P12', "P12"]
    ]),"ds")
    this.setPreviousStatement(true,null);
      this.setNextStatement(true,null);
    this.setTooltip('');
}
};


// //温度传感器获取温度
// Blockly.Blocks.ph_requestds = {
// init:function(){
//   this.setColour("#00B1AC");
//   this.appendDummyInput("")
//    .appendField(new Blockly.FieldImage(staticImg+"/3.DS18B20.svg", 84, 42))
//     .appendField(Blockly.Msg.PH_REQUESTDS)
//     this.setPreviousStatement(true,null);
//       this.setNextStatement(true,null);
//     this.setTooltip('');
// }
// };
//温度传感器初始化 ph_ds
Blockly.Blocks.ph_lm35 = {
  init:function(){
    this.setColour(color_sensor);
    this.appendDummyInput("")
     .appendField(new Blockly.FieldImage(staticImg+"/3.LM35 Sensor.svg", 84, 42))
      .appendField(Blockly.Msg.PH_READDHT)
      .appendField(new Blockly.FieldDropdown([
        ['P1' , "P1" ],
        ['P2' , "P2" ],
        ['P3' , "P3" ],
        ['P4' , "P4" ]
      ]),"lm35")
      this.appendDummyInput("")
      .appendField(Blockly.Msg.PH_LM35)
      this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
      this.setOutput(true, 'Number');
      this.setTooltip('');
  }
  };

//温度传感器读取温度
Blockly.Blocks.ph_readds = {
init:function(){
  this.setColour(color_sensor);
  this.appendDummyInput("")
  .appendField(new Blockly.FieldImage(staticImg+"/3.DS18B20.svg", 84, 42))
    .appendField(Blockly.Msg.PH_READDS)
this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
    this.setOutput(true, 'Number');
  this.setTooltip('');
}
};
//气体传感器
Blockly.Blocks.ph_air = {
init:function(){
  this.setColour(color_sensor);
  this.appendDummyInput("")
  .appendField(new Blockly.FieldImage(staticImg+"/6.MQ  Gas  sensor.svg", 84, 42))
    .appendField(Blockly.Msg.PH_AIR)
    .appendField(new Blockly.FieldDropdown([
      ['P5', "P5"],
      ['P6', "P6"],
      ['P7', "P7"],
    ]),"air")
    .appendField(new Blockly.FieldDropdown([
      [Blockly.Msg.PH_ANALOG, "aRead2()"],
      [Blockly.Msg.PH_DIGITAL, "dpRead1()"],
    ]),"airValue")
this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
    this.setOutput(true, 'Number');
  this.setTooltip('');
}
};
//人体热释电传感器
Blockly.Blocks.ph_body = {
init:function(){
  this.setColour(color_sensor);
  this.appendDummyInput("")
   .appendField(new Blockly.FieldImage(staticImg+"/38.Human  Body-Sensor.svg", 84, 42))
    .appendField(Blockly.Msg.PH_BODY)
    .appendField(new Blockly.FieldDropdown([
      ['P1' , "P1" ],
      ['P2' , "P2" ],
      ['P3' , "P3" ],
      ['P4' , "P4" ],
      ['P9' , "P9" ],
      ['P10', "P10"],
      ['P11', "P11"],
      ['P12', "P12"]
    ]),"body")
    .appendField(Blockly.Msg.PH_READBODY)
      this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
  this.setOutput(true, 'Boolean');
  this.setTooltip('');
}
};
//循迹传感器
Blockly.Blocks.ph_track = {
init:function(){
  this.setColour(color_sensor);
  this.appendDummyInput("")
  .appendField(new Blockly.FieldImage(staticImg+"/9.Power.svg", 84, 42))
    .appendField(Blockly.Msg.PH_TRACK)
    .appendField(new Blockly.FieldDropdown([
      ['P1' , "P1" ],
      ['P2' , "P2" ],
      ['P3' , "P3" ],
      ['P4' , "P4" ],
      ['P9' , "P9" ],
      ['P10', "P10"],
      ['P11', "P11"],
      ['P12', "P12"]
    ]),"track")
    .appendField(Blockly.Msg.PH_READTRACK)
      this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
  this.setOutput(true, 'Boolean');
  this.setTooltip('');
}
};
//mpu
Blockly.Blocks.ph_mpu = {
init:function(){
  this.setColour(color_sensor);
  this.appendDummyInput("")
   .appendField(new Blockly.FieldImage(staticImg+"/19.6-Axis （Gyro+Accelerometer）.svg", 84, 42))
    .appendField(Blockly.Msg.PH_MPU)
      .appendField(Blockly.Msg.PH_READMPU)
      .appendField(new Blockly.FieldDropdown([
        [Blockly.Msg.PH_XAXIS, "GetGravity(BT_X)"],
        [Blockly.Msg.PH_YAXIS, "GetGravity(BT_Y)"],
        [Blockly.Msg.PH_ZAXIS, "GetGravity(BT_Z)"],
        [Blockly.Msg.PH_ROLL, "GetRoll()"],
        [Blockly.Msg.PH_PITCH, "GetPitch()"],
       
      ]),"mpu2")
this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
    this.setOutput(true, 'Number');
  this.setTooltip('');
}
};

//红外发送
Blockly.Blocks.ph_irsend = {
init:function(){
this.setColour(color_do);
this.appendDummyInput("")
 .appendField(new Blockly.FieldImage(staticImg+"/20.Infrared emission Module.svg", 84, 42))
   .appendField(Blockly.Msg.PH_IRSENDPIN)
   .appendField(new Blockly.FieldDropdown([
    ['P1' , "P1" ],
    ['P2' , "P2" ],
    ['P3' , "P3" ],
    ['P4' , "P4" ],
    ['P9' , "P9" ],
    ['P10', "P10"],
    ['P11', "P11"],
    ['P12', "P12"]
  ]),"irsend")
    this.appendValueInput("irdata2", Number)
    .appendField(Blockly.Msg.PH_IRDATA)
   
    this.setPreviousStatement(true,null);
  this.setNextStatement(true,null);
this.setTooltip('');
}
};
//普通遥控器按下
Blockly.Blocks.ph_irKeyPress = {
  init:function(){
  this.setColour(color_do);
  this.appendDummyInput("")
  .appendField(new Blockly.FieldImage(staticImg+"/IR Remote Control.svg", 84, 42))
  .appendField(Blockly.Msg.PH_IRKEYPRESSPORT)
   .appendField(new Blockly.FieldDropdown([
    ['P9' , "P9" ],
    ['P10', "P10"],
    ['P11', "P11"],
    ['P12', "P12"]
   ]),"irKeyPort")
  .appendField(Blockly.Msg.PH_NORMALIR)
  .appendField(new Blockly.FieldDropdown([
    ['1', "IR_KEYCODE_1"],
    ['2', "IR_KEYCODE_2"],
    ['3', "IR_KEYCODE_3"],
    ['4', "IR_KEYCODE_4"],
    ['5', "IR_KEYCODE_5"],
    ['6', "IR_KEYCODE_6"],
    ['7', "IR_KEYCODE_7"],
    ['8', "IR_KEYCODE_8"],
    ['9', "IR_KEYCODE_9"],
    ['0', "IR_KEYCODE_0"],
    ['*', "IR_KEYCODE_STAR"],
    ['#', "IR_KEYCODE_POUND"],
    ['↑', "IR_KEYCODE_UP"],
    ['↓', "IR_KEYCODE_DOWN"],
    ['OK', "IR_KEYCODE_OK"],
    ['←', "IR_KEYCODE_LEFT"],
    ['→', "IR_KEYCODE_RIGHT"],
  ]),"irkey")
     this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
  this.setOutput(true, 'Boolean');
  this.setTooltip('');
  }
  };
  //emakefun遥控器按下
  Blockly.Blocks.ph_emakefunIrKeyPress = {
  init:function(){
  this.setColour(color_do);
  this.appendDummyInput("")
  .appendField(new Blockly.FieldImage(staticImg+"/4-1.Emakefun IR Remote Control.svg", 84, 42))
  .appendField(Blockly.Msg.PH_IREMAKEFUNPORT)
   .appendField(new Blockly.FieldDropdown([
    ['P9' , "P9" ],
    ['P10', "P10"],
    ['P11', "P11"],
    ['P12', "P12"]
   ]),"irEmakefunPort")
  .appendField(Blockly.Msg.PH_EMAKEFUNIR)
  .appendField(new Blockly.FieldDropdown([
    ['1', "EM_IR_KEYCODE_1"],
    ['2', "EM_IR_KEYCODE_2"],
    ['3', "EM_IR_KEYCODE_3"],
    ['4', "EM_IR_KEYCODE_4"],
    ['5', "EM_IR_KEYCODE_5"],
    ['6', "EM_IR_KEYCODE_6"],
    ['7', "EM_IR_KEYCODE_7"],
    ['8', "EM_IR_KEYCODE_8"],
    ['9', "EM_IR_KEYCODE_9"],
    ['0', "EM_IR_KEYCODE_0"],
    ['A', "EM_IR_KEYCODE_A"],
    ['B', "EM_IR_KEYCODE_B"],
    ['C', "EM_IR_KEYCODE_C"],
    ['D', "EM_IR_KEYCODE_D"],
    ['+', "EM_IR_KEYCODE_PLUS"],
    ['-', "EM_IR_KEYCODE_REDUCE"],
    ['↑', "EM_IR_KEYCODE_UP"],
    ['↓', "EM_IR_KEYCODE_DOWN"],
    ['OK', "EM_IR_KEYCODE_OK"],
    ['←', "EM_IR_KEYCODE_LEFT"],
    ['→', "EM_IR_KEYCODE_RIGHT"],
  ]),"irEmakefunkey")
     this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
  this.setOutput(true, 'Boolean');
  this.setTooltip('');
  }
  };

//蜂鸣器播放选择声音
Blockly.Blocks.ph_buzzerplay2 = {
  init:function(){
  this.setColour(color_do);
  this.appendDummyInput("")
  .appendField(new Blockly.FieldImage(staticImg+"/7.Passlve  Buzzer Module.svg", 84, 42))
    .appendField(Blockly.Msg.PH_BUZZERPLAY_PIN2)
      .appendField(new Blockly.FieldDropdown([
        ['P1' , "P1" ],
        ['P2' , "P2" ],
        ['P3' , "P3" ],
        ['P4' , "P4" ],
        ['P9' , "P9" ],
        ['P10', "P10"],
        ['P11', "P11"],
        ['P12', "P12"]
      ]),"phBuzzerInitPort")
    this.appendDummyInput("")
    .appendField(Blockly.Msg.PH_BUZZERPLAY_PLAY)
    .appendField(new Blockly.FieldDropdown([
        [Blockly.Msg.PH_CONNECTION, "S_connection"],
        [Blockly.Msg.PH_DISCONNECTION, "S_disconnection"],
        [Blockly.Msg.PH_BUTTONPUSHED, "S_buttonPushed"],
        [Blockly.Msg.PH_MODE3, "S_mode3"],
        [Blockly.Msg.PH_SURPRISE, "S_surprise"],
        [Blockly.Msg.PH_OHOH, "S_OhOoh"],
        [Blockly.Msg.PH_OHOH2, "S_OhOoh2"],
        [Blockly.Msg.PH_CUDDLY, "S_cuddly"],
        [Blockly.Msg.PH_HAPPY, "S_happy"],
        [Blockly.Msg.PH_FART1, "S_sad1"],
        [Blockly.Msg.PH_FART2, "S_sad2"],
        [Blockly.Msg.PH_CALLPOLICE, "S_callPolice"],
        [Blockly.Msg.PH_STOP, "S_stop"],
      ]),"ph_songs")
      this.appendDummyInput("")
    .appendField(Blockly.Msg.PH_BUZZERPLAY_SOND)
  this.setPreviousStatement(true,null);
   this.setNextStatement(true,null);
  this.setTooltip('');
  }
  };




//红外接收
Blockly.Blocks.ph_irreceive = {
init:function(){
this.setColour(color_do);
this.appendDummyInput("")
 .appendField(new Blockly.FieldImage(staticImg+"/18.IR  Receiver.svg", 84, 42))
   .appendField(Blockly.Msg.PH_IRRECEIVE)
   .appendField(new Blockly.FieldDropdown([
    ['P9' , "P9" ],
    ['P10', "P10"],
    ['P11', "P11"],
    ['P12', "P12"]
   ]),"irreceive")
   .appendField(Blockly.Msg.PH_ISRECEIVED)
     this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
 this.setOutput(true, 'Boolean');
 this.setTooltip('');
}
};
//红外接收传感器接收的值
Blockly.Blocks.ph_irreceivedata = {
init:function(){
  this.setColour(color_do);
  this.appendDummyInput("")
  .appendField(new Blockly.FieldImage(staticImg+"/18.IR  Receiver.svg", 84, 42))
    .appendField(Blockly.Msg.PH_IRRECEIVEDATA)
this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
    this.setOutput(true, 'Number');
  this.setTooltip('');
}
};
//红外接收传感器接收下一个值
Blockly.Blocks.ph_irreceivenext = {
init:function(){
this.setColour(color_do);
this.appendDummyInput("")
 .appendField(new Blockly.FieldImage(staticImg+"/18.IR  Receiver.svg", 84, 42))
   .appendField(Blockly.Msg.PH_IRRECEIVENEXT)
this.setPreviousStatement(true,null);
  this.setNextStatement(true,null);
this.setTooltip('');
}
};
//有源蜂鸣器 ph_buzzer
Blockly.Blocks.ph_buzzer = {
init:function(){
this.setColour(color_do);
this.appendDummyInput("")
 .appendField(new Blockly.FieldImage(staticImg+"/7.Passlve  Buzzer Module.svg", 84, 42))
   .appendField(Blockly.Msg.PH_PASSIVEBUZZER)
   .appendField(new Blockly.FieldDropdown([
    ['P1' , "P1" ],
    ['P2' , "P2" ],
    ['P3' , "P3" ],
    ['P4' , "P4" ],
    ['P9' , "P9" ],
    ['P10', "P10"],
    ['P11', "P11"],
    ['P12', "P12"]
   ]),"buzzer")
    this.appendValueInput("buzzers", Number)
    .appendField(Blockly.Msg.PH_HZ)
    this.appendValueInput("time", Number)
    .appendField(Blockly.Msg.PH_TIME);
this.setPreviousStatement(true,null);
  this.setNextStatement(true,null);
this.setTooltip('');
}
};

//无源蜂鸣器 ph_buzzer
Blockly.Blocks.ph_buzzer1 = {
  init:function(){
  this.setColour(color_do);
  this.appendDummyInput("")
   .appendField(new Blockly.FieldImage(staticImg+"/1.Buzzer  Module.svg", 84, 42))
     .appendField(Blockly.Msg.PH_BUZZER)
     .appendField(new Blockly.FieldDropdown([
      ['P1' , "P1" ],
      ['P2' , "P2" ],
      ['P3' , "P3" ],
      ['P4' , "P4" ],
      ['P9' , "P9" ],
      ['P10', "P10"],
      ['P11', "P11"],
      ['P12', "P12"]
     ]),"passiveBuzzer")
      this.appendValueInput("play_time", Number)
      .appendField(Blockly.Msg.PH_TIME);
  this.setPreviousStatement(true,null);
    this.setNextStatement(true,null);
  this.setTooltip('');
  }
  };

//直流电机
Blockly.Blocks.ph_motor = {
init:function(){
this.setColour(color_do);
this.appendDummyInput("")
 .appendField(new Blockly.FieldImage(staticImg+"/21.Motor-Module.svg", 84, 42))
   .appendField(Blockly.Msg.PH_MOTOR)
   .appendField(new Blockly.FieldDropdown([
     ['P8', "P8"],
     ['P7', "P7"],
     ['P6', "P6"],
     ['P5', "P5"],
   ]),"motor")
   .appendField(new Blockly.FieldDropdown([
     [Blockly.Msg.PH_FORWARD, "forward"],
     [Blockly.Msg.PH_REVERSE, "reverse"],
   ]),"direction")
    this.appendValueInput("motorSpeed", Number)
    .appendField(Blockly.Msg.PH_SPEED)
this.setPreviousStatement(true,null);
  this.setNextStatement(true,null);
this.setTooltip('');
}
};

//双电机驱动
Blockly.Blocks.ph_dcMotorDriver = {
  init:function(){
  this.setColour(color_do);
  this.appendDummyInput("")
  .appendField(new Blockly.FieldImage(staticImg+"/51.High Speed Mini Motor Drive Board.svg", 84, 42))
    .appendField(Blockly.Msg.PH_DCMOTOR_PIN)
    .appendField(new Blockly.FieldDropdown([
      ['P13', "P13"],
    ]),"driverPin")
    this.appendValueInput("phDcMotors1", Number)
    // .appendField(Blockly.Msg.PH_DCMOTORSPEED1)
    .appendField(Blockly.Msg.PH_DCMOTORSPEED1)
    this.appendValueInput("phDcMotors2", Number)
    .appendField(Blockly.Msg.PH_DCMOTORSPEED2)
  this.setPreviousStatement(true,null);
   this.setNextStatement(true,null);
  this.setTooltip('');
  }
};
  //双电机速度
Blockly.Blocks.ph_dcMotorSpeed = {
  init:function(){
  this.setColour(color_do);
  this.appendDummyInput("")
  .appendField(new Blockly.FieldImage(staticImg+"/51.High Speed Mini Motor Drive Board.svg", 84, 42))
     this.appendValueInput("phDcMotors1", Number)
     .appendField(Blockly.Msg.PH_DCMOTORSPEED1)
     this.appendValueInput("phDcMotors2", Number)
     .appendField(Blockly.Msg.PH_DCMOTORSPEED2)
  this.setPreviousStatement(true,null);
   this.setNextStatement(true,null);
  this.setTooltip('');
  }
  };

//继电器
Blockly.Blocks.ph_relay = {
init:function(){
this.setColour(color_do);
this.appendDummyInput("")
 .appendField(new Blockly.FieldImage(staticImg+"/22.Relay-Module.svg", 84, 42))
   .appendField(Blockly.Msg.PH_RELAY)
   .appendField(new Blockly.FieldDropdown([
    ['P1' , "P1" ],
    ['P2' , "P2" ],
    ['P3' , "P3" ],
    ['P4' , "P4" ],
    ['P9' , "P9" ],
    ['P10', "P10"],
    ['P11', "P11"],
    ['P12', "P12"]
   ]),"relay")
   .appendField(new Blockly.FieldDropdown([
     [Blockly.Msg.PH_OPEN, "HIGH"],
     [Blockly.Msg.PH_CLOSE, "LOW"],
   ]),"status2")
this.setPreviousStatement(true,null);
  this.setNextStatement(true,null);
this.setTooltip('');
}
};
//  tm1650数码管
Blockly.Blocks.ph_tm1650 = {
init:function(){
this.setColour(color_display);
this.appendDummyInput("")
 .appendField(new Blockly.FieldImage(staticImg+"/37.4-digit  7-segment.svg", 84, 42))
   .appendField(Blockly.Msg.PH_TM1650)
   .appendField(new Blockly.FieldDropdown([
    ["P7", "P7"],
  ]),"tm1650Port")
   .appendField(new Blockly.FieldDropdown([
     [Blockly.Msg.PH_OPEN, "displayOn()"],
     [Blockly.Msg.PH_CLOSE, "displayOff()"],
     [Blockly.Msg.PH_CLEAR, "clear()"],
   ]),"status3")
this.setPreviousStatement(true,null);
  this.setNextStatement(true,null);
this.setTooltip('');
}
};
//tm1650数码管显示
Blockly.Blocks.ph_tm1650display = {
init:function(){
this.setColour(color_display);
this.appendDummyInput("")
 .appendField(new Blockly.FieldImage(staticImg+"/37.4-digit  7-segment.svg", 84, 42))
    this.appendValueInput("tm1650displays", Number)
    .appendField(Blockly.Msg.PH_TM1650DISPLAY)
this.setPreviousStatement(true,null);
  this.setNextStatement(true,null);
this.setTooltip('');
}
};

//tm1650数码管显示
Blockly.Blocks.ph_tm1650displayNumber = {
  init:function(){
  this.setColour(color_display);
  this.appendDummyInput("")
   .appendField(new Blockly.FieldImage(staticImg+"/37.4-digit  7-segment.svg", 84, 42))
      this.appendValueInput("tm1650displaysNumber", Number)
      .appendField(Blockly.Msg.PH_TM1650DISPLAYNUMBER)
  this.setPreviousStatement(true,null);
    this.setNextStatement(true,null);
  this.setTooltip('');
  }
  };

//tm1650数码管显示小数点
Blockly.Blocks.ph_tm1650displaypoint = {
init:function(){
this.setColour(color_display);
this.appendDummyInput("")
 .appendField(new Blockly.FieldImage(staticImg+"/37.4-digit  7-segment.svg", 84, 42))
   .appendField(Blockly.Msg.PH_TM1650DISPLAYPOINT)
   .appendField(new Blockly.FieldDropdown([
     ['1', "0"],
     ['2', "1"],
     ['3', "2"],
     ['4', "3"],
   ]),"tm1650displaypoint")
   .appendField(Blockly.Msg.PH_TM1650DISPLAYPOINTNUM)
   .appendField(new Blockly.FieldDropdown([
     [Blockly.Msg.PH_BRIGHT, "true"],
     [Blockly.Msg.PH_EXTINCT, "false"],
   ]),"tm1650displaypointnum")
this.setPreviousStatement(true,null);
  this.setNextStatement(true,null);
this.setTooltip('');
}
};
//tm1637初始化
Blockly.Blocks.ph_tm1637 = {
init:function(){
this.setColour(color_display);
this.appendDummyInput("")
 .appendField(new Blockly.FieldImage(staticImg+"/23.4-digit clock 7-segment.svg", 84, 42))
   .appendField(Blockly.Msg.PH_TM1637)
   .appendField(new Blockly.FieldDropdown([
    ['P5', "P5"],
    ['P6', "P6"],
    ['P7', "P7"],
    ['P8', "P8"],
  ]),"tm1637")
this.setPreviousStatement(true,null);
  this.setNextStatement(true,null);
this.setTooltip('');
}
};
//tm1637设置亮度
Blockly.Blocks.ph_tm1637setlight = {
init:function(){
this.setColour(color_display);
this.appendDummyInput("")
 .appendField(new Blockly.FieldImage(staticImg+"/23.4-digit clock 7-segment.svg", 84, 42))
    this.appendValueInput("tm1637setlights", Number)
    .appendField(Blockly.Msg.PH_TM1637SETLIGHT)
this.setPreviousStatement(true,null);
  this.setNextStatement(true,null);
this.setTooltip('');
}
};
//tm1637显示
Blockly.Blocks.ph_tm1637display = {
init:function(){
this.setColour(color_display);
this.appendDummyInput("")
 .appendField(new Blockly.FieldImage(staticImg+"/23.4-digit clock 7-segment.svg", 84, 42))
    this.appendValueInput("tm1637displays", Number)
    .appendField(Blockly.Msg.PH_TM1637DISPLAY)
this.setPreviousStatement(true,null);
  this.setNextStatement(true,null);
this.setTooltip('');
}
};
//tm1637是否显示两点
Blockly.Blocks.ph_tm1637displayPoint = {
  init:function(){
  this.setColour(color_display);
  this.appendDummyInput("")
   .appendField(new Blockly.FieldImage(staticImg+"/23.4-digit clock 7-segment.svg", 84, 42))
   .appendField(Blockly.Msg.PH_TM1637DISPLAYTIMEPOINT)
   .appendField(new Blockly.FieldDropdown([
     ["ON", "1"],
     ["OFF", "0"],
   ]),"tm1637displaypointnum")
  this.setPreviousStatement(true,null);
    this.setNextStatement(true,null);
  this.setTooltip('');
  }
  };
//tm1637显示时间
Blockly.Blocks.ph_tm1637displaytime = {
init:function(){
this.setColour(color_display);
this.appendDummyInput("")
 .appendField(new Blockly.FieldImage(staticImg+"/23.4-digit clock 7-segment.svg", 84, 42))
   .appendField(Blockly.Msg.PH_TM1637DISPLAYTIME)
    this.appendValueInput("tm1637displaytime1", Number)
    .appendField(Blockly.Msg.PH_TM1637DISPLAYTIME1)
    this.appendValueInput("tm1637displaytime2", Number)
    .appendField(Blockly.Msg.PH_TM1637DISPLAYTIME2)
    this.appendDummyInput("")
this.setPreviousStatement(true,null);
  this.setNextStatement(true,null);
this.setTooltip('');
}
};
//tm1637清屏
Blockly.Blocks.ph_tm1637clear = {
init:function(){
this.setColour(color_display);
this.appendDummyInput("")
 .appendField(new Blockly.FieldImage(staticImg+"/23.4-digit clock 7-segment.svg", 84, 42))
    .appendField(Blockly.Msg.PH_TM1637CLEAR)
this.setPreviousStatement(true,null);
  this.setNextStatement(true,null);
this.setTooltip('');
}
};
//rgb
Blockly.Blocks.ph_rgb = {
init:function(){
this.setColour(color_display);
this.appendDummyInput("")
 .appendField(new Blockly.FieldImage(staticImg+"/10.RGB-Module.svg", 84, 42))
   .appendField(Blockly.Msg.PH_RGB)
   .appendField(new Blockly.FieldDropdown([
     ['P15', "P15"],
     ['P16', "P16"],
   ]),"rgb")
    this.appendValueInput("rgb1", Number)
    .appendField(Blockly.Msg.PH_RGBNUM)
    this.appendValueInput("rgb2", Number)
    .appendField(Blockly.Msg.PH_RGBLIGHT)
this.setPreviousStatement(true,null);
  this.setNextStatement(true,null);
this.setTooltip('');
}
};
//rgb颜色
Blockly.Blocks.ph_rgbcolor = {
init:function(){
this.setColour(color_display);
this.appendDummyInput("")
 .appendField(new Blockly.FieldImage(staticImg+"/10.RGB-Module.svg", 84, 42))
 .appendField(Blockly.Msg.PH_RGB)
 .appendField(new Blockly.FieldDropdown([
   ['P15', "P15"],
   ['P16', "P16"],
 ]),"rgb")
 .appendField(Blockly.Msg.PH_DISPLAYCOLOR)
 this.appendValueInput("COLOR", Number)
this.setPreviousStatement(true,null);
  this.setNextStatement(true,null);
this.setTooltip('');
}
};

//rgb颜色
Blockly.Blocks.ph_ringRgbColorInit = {
  init:function(){
  this.setColour(color_display);
  this.appendDummyInput("")
   .appendField(new Blockly.FieldImage(staticImg+"/RGB Light Ring.svg", 84, 42))
   .appendField(Blockly.Msg.PH_RGBRING)
   .appendField(new Blockly.FieldDropdown([
    ['P5' , "P5" ],
    ['P6' , "P6" ],
    ['P7' , "P7" ],
    ['P8' , "P8" ],
   ]),"rgbRing")
   
  this.setPreviousStatement(true,null);
    this.setNextStatement(true,null);
  this.setTooltip('');
  }
  };

//rgb颜色亮度
Blockly.Blocks.ph_setRingRgbLight = {
  init:function(){
  this.setColour(color_display);
  this.appendDummyInput("")
   .appendField(new Blockly.FieldImage(staticImg+"/RGB Light Ring.svg", 84, 42))
   .appendField(Blockly.Msg.PH_SETRGBRINGLIGHT)
   this.appendValueInput("rgbLight", Number)
   .appendField(Blockly.Msg.PH_RGBRINGLIGHT)
  this.setPreviousStatement(true,null);
    this.setNextStatement(true,null);
  this.setTooltip('');
  }
  };



//rgb颜色
Blockly.Blocks.ph_ringRgbColor = {
  init:function(){
  this.setColour(color_display);
  this.appendDummyInput("")
   .appendField(new Blockly.FieldImage(staticImg+"/RGB Light Ring.svg", 84, 42))
   .appendField(Blockly.Msg.PH_RGBRING1)
   this.appendValueInput("total", Number)
   .appendField(Blockly.Msg.PH_RGBTOTAL)
   this.appendValueInput("start", Number)
   .appendField(Blockly.Msg.PH_RGBSTART)
   this.appendValueInput("end", Number)
   .appendField(Blockly.Msg.PH_RGBEND)
   this.appendValueInput("lightTime", Number)
   .appendField(Blockly.Msg.PH_TIME)
   this.appendValueInput("COLOR", Number)
   .appendField(Blockly.Msg.PH_RGBULTRASONICSETCOLORLED)
  this.setPreviousStatement(true,null);
    this.setNextStatement(true,null);
  this.setTooltip('');
  }
  };


// 摇杆
Blockly.Blocks.ph_rock = {


  init:function(){
    this.setColour(base_color);
    this.appendDummyInput("")
    .appendField(new Blockly.FieldImage(staticImg+"/31.Rocker - Module.svg", 84, 42))
          .appendField(Blockly.Msg.PH_ROCK)


      .appendField(new Blockly.FieldDropdown([
        ['P16', "P16"]
      ]),"rock")
        .appendField(Blockly.Msg.PH_READROCK)
        .appendField(new Blockly.FieldDropdown([
          [Blockly.Msg.PH_ROCKLEFT, "rock.aRead3()==1023"],
          [Blockly.Msg.PH_ROCKRIGHT, "rock.aRead3()==0"],
          [Blockly.Msg.PH_ROCKUP, "rock.aRead4()==0"],
          [Blockly.Msg.PH_ROCKDOWN, "rock.aRead4()==1023"],
          [Blockly.Msg.PH_BUTTON, "rock.dRead5() == 0"],
          [Blockly.Msg.PH_NOTBUTTON, "rock.dRead5() == 1"]
        ]),"rock2")
        this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
    this.setOutput(true, 'Boolean');
    this.setTooltip('');
  }
};
//钢琴模块
Blockly.Blocks.ph_piano = {
init:function(){
this.setColour(base_color);
this.appendDummyInput("")
 .appendField(new Blockly.FieldImage(staticImg+"/33.Touch  Piano.svg", 84, 42))
   .appendField(Blockly.Msg.PH_PIANO)
   .appendField(new Blockly.FieldDropdown([
    ['P5', "P5"],
    ['P6', "P6"],
    ['P7', "P7"],
   ]),"piano")
   .appendField(Blockly.Msg.PH_PIANOPRESS)
   .appendField(new Blockly.FieldDropdown([
     ['1', "BS_KEYCODE_1"],
     ['2', "BS_KEYCODE_2"],
     ['3', "BS_KEYCODE_3"],
     ['4', "BS_KEYCODE_4"],
     ['5', "BS_KEYCODE_5"],
     ['6', "BS_KEYCODE_6"],
     ['7', "BS_KEYCODE_7"],
     ['8', "BS_KEYCODE_8"],
   ]),"piano2")
   this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
 this.setOutput(true, 'Boolean');
 this.setTooltip('');
}
};
//旋转电位器
Blockly.Blocks.ph_resistance = {
init:function(){
  this.setColour(base_color);
  this.appendDummyInput("")
   .appendField(new Blockly.FieldImage(staticImg+"/16.Rotary  potentiometer.svg", 84, 42))
    .appendField(Blockly.Msg.PH_RESISTANCE)
    .appendField(new Blockly.FieldDropdown([
      ['P1' , "P1" ],
      ['P2' , "P2" ],
      ['P3' , "P3" ],
      ['P4' , "P4" ],
    ]),"resistance")
      .appendField(Blockly.Msg.PH_READRESISTANCE)
this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
    this.setOutput(true, 'Number');
  this.setTooltip('');
}
};
//滑动电位器
Blockly.Blocks.ph_slipresistance = {
init:function(){
  this.setColour(base_color);
  this.appendDummyInput("")
   .appendField(new Blockly.FieldImage(staticImg+"/32.Slide  Potentiometer.svg", 84, 42))
    .appendField(Blockly.Msg.PH_SLIPRESISTANCE)
    .appendField(new Blockly.FieldDropdown([
      ['P1' , "P1" ],
      ['P2' , "P2" ],
      ['P3' , "P3" ],
      ['P4' , "P4" ],
    ]),"slipresistance")
      .appendField(Blockly.Msg.PH_READSLIPRESISTANCE)
this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
    this.setOutput(true, 'Number');
  this.setTooltip('');
}
};
//红绿灯
Blockly.Blocks.ph_trafficlights = {
init:function(){
this.setColour(color_display);
this.appendDummyInput("")
 .appendField(new Blockly.FieldImage(staticImg+"/27.Water  ljght Module.svg", 84, 42))
   .appendField(Blockly.Msg.PH_TRIFFICLIGHTS)
   .appendField(new Blockly.FieldDropdown([
     ['P15', "P15"],
     ['P16', "P16"],
   ]),"trafficlights")
   .appendField(Blockly.Msg.PH_TRIFFICLIGHTSRED)
   .appendField(new Blockly.FieldDropdown([
    [Blockly.Msg.PH_BRIGHT, "1"],
    [Blockly.Msg.PH_EXTINCT, "0"],
  ]),"trafficlights2")
  .appendField(Blockly.Msg.PH_TRIFFICLIGHTSGREEN)
  .appendField(new Blockly.FieldDropdown([
    [Blockly.Msg.PH_BRIGHT, "1"],
    [Blockly.Msg.PH_EXTINCT, "0"],
  ]),"trafficlights3")
  .appendField(Blockly.Msg.PH_TRIFFICLIGHTSYELLOW)
   .appendField(new Blockly.FieldDropdown([
     [Blockly.Msg.PH_BRIGHT, "1"],
     [Blockly.Msg.PH_EXTINCT, "0"],
   ]),"trafficlights4")
   this.appendValueInput("lightTime", Number)
   .appendField(Blockly.Msg.PH_SHOWTIME)
this.setPreviousStatement(true,null);
  this.setNextStatement(true,null);
this.setTooltip('');
}
};
//流水灯
Blockly.Blocks.ph_waterlights = {
init:function(){
this.setColour(color_display);
this.appendDummyInput("")

 .appendField(new Blockly.FieldImage(staticImg+"/11.Running Water light.svg", 84, 42))


   .appendField(Blockly.Msg.PH_WHATERLIGHTS)
   .appendField(new Blockly.FieldDropdown([
     ['1', "1"],
     ['2', "2"],
     ['3', "3"],
     ['4', "4"],
     ['5', "5"],
     ['6', "6"],
     ['7', "7"],
     ['8', "8"],
     ['9', "9"],
     ['10', "10"],
     ['11', "11"],
     ['12', "12"],
     ['13', "13"],
     ['14', "14"],
   ]),"waterlights")
   .appendField(new Blockly.FieldDropdown([
     [Blockly.Msg.PH_BRIGHT, "1"],
     [Blockly.Msg.PH_EXTINCT, "0"],
   ]),"waterlights1")
this.setPreviousStatement(true,null);
  this.setNextStatement(true,null);
this.setTooltip('');
}
};
//8x8点阵屏初始化
Blockly.Blocks.ph_max = {
init:function(){
this.setColour(color_display);
this.appendDummyInput("")
 .appendField(new Blockly.FieldImage(staticImg+"/24. 8x8.svg", 84, 42))
   .appendField(Blockly.Msg.PH_MAX)
   .appendField(new Blockly.FieldDropdown([
     ['P15', "P15"],
     ['P16', "P16"],
   ]),"max")
    .appendField(Blockly.Msg.PH_MAXS)
   this.appendValueInput("maxs", Number)
this.setPreviousStatement(true,null);
  this.setNextStatement(true,null);
this.setTooltip('');
}
};

// //点阵屏显示
// Blockly.Blocks.MAX7219_DisplayChar = {
//   init:function(){
//   this.setColour(color_display);
//    this.appendDummyInput("")
//      .appendField(Blockly.Msg.ARDUINO_MAXPRINT)
//      .appendField(new Blockly.FieldDropdown([
//       ['0', "0"],
//       ['1', "1"],
//       ['2', "2"],
//       ['3', "3"],
//       ['4', "4"],
//       ['5', "5"],
//       ['6', "6"],
//       ['7', "7"],
//       ['8', "8"],
//       ['9', "9"],
//       [Blockly.Msg.ARDUINO_MSMILE, "10"],
//     [Blockly.Msg.ARDUINO_MBIGSMILE, "11"],
//       [Blockly.Msg.ARDUINO_MHAHA, "12"],
//       [Blockly.Msg.ARDUINO_MHEART, "13"],
//       [Blockly.Msg.ARDUINO_MSURPRISE, "14"],
//       [Blockly.Msg.ARDUINO_MLITTLESURPRISE, "15"],
//       [Blockly.Msg.ARDUINO_MTONE, "16"],
//       [Blockly.Msg.ARDUINO_MTOOTH1, "17"],
//       [Blockly.Msg.ARDUINO_MTOOTH2, "18"],
//       [Blockly.Msg.ARDUINO_MLINE, "19"],
//       [Blockly.Msg.ARDUINO_MCONFUSED, "20"],
//     [Blockly.Msg.ARDUINO_MLINE2, "21"],
//       [Blockly.Msg.ARDUINO_MSAD1, "22"],
//       [Blockly.Msg.ARDUINO_MSAD2, "23"],
//       [Blockly.Msg.ARDUINO_MSAD3, "24"],
//       ['√', "25"],
//       ['×', "26"],
//       ['?', "27"],
//       [Blockly.Msg.ARDUINO_MLIGHT, "28"],
//       [Blockly.Msg.ARDUINO_MMOUTH, "29"],
//       [Blockly.Msg.ARDUINO_MMAD, "30"],

//     ]),"draw")
//   this.setPreviousStatement(true,null);
//    this.setNextStatement(true,null);
//   this.setTooltip('');
//   }
//   };


//8x8点阵屏单点亮或灭
Blockly.Blocks.ph_maxpoint = {
init:function(){
this.setColour(color_display);
this.appendDummyInput("")
 .appendField(new Blockly.FieldImage(staticImg+"/24. 8x8.svg", 84, 42))


 .appendField(Blockly.Msg.PH_MAXPRINT)
 .appendField(new Blockly.FieldDropdown([
  ['0', "0"],
  ['1', "1"],
  ['2', "2"],
  ['3', "3"],
  ['4', "4"],
  ['5', "5"],
  ['6', "6"],
  ['7', "7"],
  ['8', "8"],
  ['9', "9"],
  [Blockly.Msg.PH_MSMILE, "10"],
  [Blockly.Msg.PH_MBIGSMILE, "11"],
  [Blockly.Msg.PH_MHAHA, "12"],
  [Blockly.Msg.PH_MHEART, "13"],
  [Blockly.Msg.PH_MSURPRISE, "14"],
  [Blockly.Msg.PH_MLITTLESURPRISE, "15"],
  [Blockly.Msg.PH_MTONE, "16"],
  [Blockly.Msg.PH_MTOOTH1, "17"],
  [Blockly.Msg.PH_MTOOTH2, "18"],
  [Blockly.Msg.PH_MLINE, "19"],
  [Blockly.Msg.PH_MCONFUSED, "20"],
  [Blockly.Msg.PH_MLINE2, "21"],
  [Blockly.Msg.PH_MSAD1, "22"],
  [Blockly.Msg.PH_MSAD2, "23"],
  [Blockly.Msg.PH_MSAD3, "24"],
  ['√', "25"],
  ['×', "26"],
  ['?', "27"],
  [Blockly.Msg.PH_MLIGHT, "28"],
  [Blockly.Msg.PH_MMOUTH, "29"],
  [Blockly.Msg.PH_MMAD, "30"],
 ]),"draw")


this.setPreviousStatement(true,null);
  this.setNextStatement(true,null);
this.setTooltip('');
}
};
//8x8点阵屏点选
Blockly.Blocks.ph_x8leddisplay = {
  init:function(){
  this.setColour(color_display);
  this.appendDummyInput("")
   .appendField(new Blockly.FieldImage(staticImg+"/24. 8x8.svg", 84, 42))
     .appendField(Blockly.Msg.PH_X8LEDDISPLAY)
     .appendField(new Blockly.LatticeAdapter(),"draws")

     this.setPreviousStatement(true,null);
       this.setNextStatement(true,null);
     this.setTooltip('');
   }
};

//手势传感器获取值
Blockly.Blocks.ph_handle_gesture = {
  init:function(){
    this.setColour(color_sensor);
    this.appendDummyInput("")

     .appendField(new Blockly.FieldImage(staticImg+"/17.Gesture  Recognition Module.svg", 84, 42))


          .appendField(Blockly.Msg.PH_HANDLE_GESTURE)
          .appendField(new Blockly.FieldDropdown([
            [Blockly.Msg.PH_GESTUREUP, "DIR_UP"],
            [Blockly.Msg.PH_GESTUREDOWN, "DIR_DOWN"],
            [Blockly.Msg.PH_GESTURELEFT, "DIR_LEFT"],
            [Blockly.Msg.PH_GESTURERIGHT, "DIR_RIGHT"],
            [Blockly.Msg.PH_GESTURENEAR, "DIR_NEAR"],
            [Blockly.Msg.PH_GESTUREFAR, "DIR_FAR"],
          ]),"gestureStatus")

      this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
    this.setOutput(true, 'Boolean');
    this.setTooltip('');
   
  }
};

//手势传感器初始化
Blockly.Blocks.ph_handleGestureInit = {
  init:function(){
    this.setColour(color_sensor);
    this.appendDummyInput("")

     .appendField(new Blockly.FieldImage(staticImg+"/17.Gesture  Recognition Module.svg", 84, 42))


          .appendField(Blockly.Msg.PH_HANDLEGESTUREINIT)
    // this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
    this.setPreviousStatement(true,null);
    this.setNextStatement(true,null);
    this.setTooltip('');
    // this.setOutput(true, 'Boolean');
    // this.setTooltip('');
  }
};

//手势传感器是否获取到手势
Blockly.Blocks.ph_gesture = {
  init:function(){
    this.setColour(color_sensor);
    this.appendDummyInput("")


     .appendField(new Blockly.FieldImage(staticImg+"/17.Gesture  Recognition Module.svg", 84, 42))


          .appendField(Blockly.Msg.PH_GESTURE)
    this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
    this.setOutput(true, 'Boolean');
    this.setTooltip('');
  }
};

//手势传感器状态
Blockly.Blocks.ph_gestureStatus = {
  init:function(){
    this.setColour(color_sensor);
    this.appendDummyInput("")

     .appendField(new Blockly.FieldImage(staticImg+"/17.Gesture  Recognition Module.svg", 84, 42))
          .appendField(Blockly.Msg.PH_GESTURESTATUS)
          this.setPreviousStatement(true,null);
          this.setNextStatement(true,null);
          this.setTooltip('');


  }
};

//旋转编码器初始化
Blockly.Blocks.ph_ec11Init = {
  init:function(){
    this.setColour(base_color);
    this.appendDummyInput("")


     .appendField(new Blockly.FieldImage(staticImg+"/15.Rotary  encoder Module.svg", 84, 42))
          .appendField(Blockly.Msg.PH_EC11IINTERFACE)
          .appendField(new Blockly.FieldDropdown([
            ["P15", "P15"],
            ["P16", "P16"],
           ]),"rotary")
      .appendField(Blockly.Msg.PH_EC11INIT)
    this.setPreviousStatement(true,null);
    this.setNextStatement(true,null);


    this.setTooltip('');
  }
};

//旋转编码器按钮是否按下
Blockly.Blocks.ph_ec11ButtonPushDown = {
  init:function(){
    this.setColour(base_color);
    this.appendDummyInput("")


     .appendField(new Blockly.FieldImage(staticImg+"/15.Rotary  encoder Module.svg", 84, 42))
          .appendField(Blockly.Msg.PH_EC11BUTTONPUSHDOWN)
    this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
    this.setOutput(true, 'Boolean');


    this.setTooltip('');
  }
};

//旋转编码器数值
Blockly.Blocks.ph_ec11 = {
  init:function(){
    this.setColour(base_color);
    this.appendDummyInput("")

     .appendField(new Blockly.FieldImage(staticImg+"/15.Rotary  encoder Module.svg", 84, 42))
          .appendField(Blockly.Msg.PH_EC11)


    this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
    this.setOutput(true, 'Number');
    this.setTooltip('');
  }
};

//灰度传感器读值
Blockly.Blocks.ph_grayscale = {
  init:function(){
    this.setColour(color_sensor);
    this.appendDummyInput("")


     .appendField(new Blockly.FieldImage(staticImg+"/46-Grayscale Sensor.svg", 84, 42))
          .appendField(Blockly.Msg.PH_GRAYSCALE)
          .appendField(new Blockly.FieldDropdown([
            ['P1' , "P1" ],
            ['P2' , "P2" ],
            ['P3' , "P3" ],
            ['P4' , "P4" ],
            ['P9' , "P9" ],
            ['P10', "P10"],
            ['P11', "P11"],
            ['P12', "P12"]
           ]),"grayscale")
           .appendField(Blockly.Msg.PH_ANALOG)
    this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);


    this.setOutput(true, 'Number');
    this.setTooltip('');
  }
};

//震动传感器读值
Blockly.Blocks.ph_shock = {
  init:function(){
    this.setColour(color_sensor);
    this.appendDummyInput("")

     .appendField(new Blockly.FieldImage(staticImg+"/47-Shock Sensor.svg", 84, 42))
          .appendField(Blockly.Msg.PH_SHOCK)
          .appendField(new Blockly.FieldDropdown([
            ['P5', "P5"],
            ['P6', "P6"],
            ['P7', "P7"],
            ['P8', "P8"],
           ]),"shockPin")
           .appendField(Blockly.Msg.PH_READFIRE)
           .appendField(new Blockly.FieldDropdown([
            [Blockly.Msg.PH_ANALOG, "aRead2()"],
            [Blockly.Msg.PH_DIGITAL, "dpRead1()"]
           ]),"shockValue")
    this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
    this.setOutput(true, 'Number');
    this.setTooltip('');
  }
};


//倾斜传感器 是否倾斜
Blockly.Blocks.ph_tilt = {
  init:function(){
    this.setColour(color_sensor);
    this.appendDummyInput("")
     .appendField(new Blockly.FieldImage(staticImg+"/48-Tilt Switch Sensor.svg", 84, 42))
          .appendField(Blockly.Msg.PH_TILT)
          .appendField(new Blockly.FieldDropdown([
            ['P1' , "P1" ],
            ['P2' , "P2" ],
            ['P3' , "P3" ],
            ['P4' , "P4" ],
            ['P9' , "P9" ],
            ['P10', "P10"],
            ['P11', "P11"],
            ['P12', "P12"]
           ]),"tilt")
           .appendField(Blockly.Msg.PH_ISTILT)
    this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
    this.setOutput(true, 'Boolean');
    this.setTooltip('');
  }
};




//磁簧开关传感器是否检测到磁场
Blockly.Blocks.ph_reed_switch = {
  init:function(){
    this.setColour(color_sensor);
    this.appendDummyInput("")
     .appendField(new Blockly.FieldImage(staticImg+"/5.Magnetic   Switch.svg", 84, 42))
          .appendField(Blockly.Msg.PH_REEDSWITCH)
          .appendField(new Blockly.FieldDropdown([
            ['P1' , "P1" ],
            ['P2' , "P2" ],
            ['P3' , "P3" ],
            ['P4' , "P4" ],
            ['P9' , "P9" ],
            ['P10', "P10"],
            ['P11', "P11"],
            ['P12', "P12"]
           ]),"reedPort")
           .appendField(Blockly.Msg.PH_ISREED)
    this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
    this.setOutput(true, 'Boolean');
    this.setTooltip('');
  }
};

//超声波传感器读值
Blockly.Blocks.ph_ultrasonic = {
  init:function(){
    this.setColour(color_sensor);
    this.appendDummyInput("")
     .appendField(new Blockly.FieldImage(staticImg+"/40.ph_ultrasonic.svg", 84, 42))
          .appendField(Blockly.Msg.PH_ULTRASONIC)
          .appendField("Echo")
          .appendField(new Blockly.FieldDropdown([
            ['D4', "4"],
            ['D1', "1"],
            ['D2', "2"],
            ['D3', "3"],
            ['D5', "5"],
            ['D6', "6"],
            ['D7', "7"],
            ['D8', "8"],
            ['D9', "9"],
            ['D10', "10"],
            ['D11', "11"],
            ['D12', "12"],
            ['D13', "13"],
            ['A0', "A0"],
            ['A1', "A1"],
            ['A2', "A2"],
            ['A3', "A3"],
            ['A4', "A4"],
            ['A5', "A5"],
           ]),"echo")
           .appendField("Trig")
           .appendField(new Blockly.FieldDropdown([
            ['D2', "2"],
            ['D1', "1"],
            ['D3', "3"],
            ['D4', "4"],
            ['D5', "5"],
            ['D6', "6"],
            ['D7', "7"],
            ['D8', "8"],
            ['D9', "9"],
            ['D10', "10"],
            ['D11', "11"],
            ['D12', "12"],
            ['D13', "13"],
            ['A0', "A0"],
            ['A1', "A1"],
            ['A2', "A2"],
            ['A3', "A3"],
            ['A4', "A4"],
            ['A5', "A5"],
            ]),"trig")
          //  .appendField(Blockly.Msg.PH_DISTANCE)
    this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
    this.setOutput(true, 'Number');
    this.setTooltip('');
  }
};

//舵机
Blockly.Blocks.ph_servo = {
  init:function(){
  this.setColour(color_do);
  this.appendDummyInput("")
  .appendField(new Blockly.FieldImage(staticImg+"/Servo.svg", 84, 42))
    .appendField(Blockly.Msg.PH_INITSERVOPIN)
     .appendField(new Blockly.FieldDropdown([
      ['D3', "3" ],
      ['D4', "4" ],
      ['10' , "10" ],
     ]),"phservopins")
     .appendField(Blockly.Msg.PH_SERVOANGLE)
     this.appendValueInput("phservoangle", Number)
  this.setPreviousStatement(true,null);
   this.setNextStatement(true,null);
  this.setTooltip('');
  }
  };

//串口波特率
Blockly.Blocks.ph_serialbegin = {
  init:function(){
  this.setColour(color_serial);
  this.appendDummyInput("")
    .appendField(Blockly.Msg.PH_BAUDRATE)
    .appendField(new Blockly.FieldDropdown([
    ['Serial', "Serial"],
    ['softwareSerial', "softwareSerial"],
  ]),"SerialS1")
  .appendField(Blockly.Msg.PH_BAUDRATES)
    .appendField(new Blockly.FieldDropdown([
      ['4800', "4800"],
      ['9600', "9600"],
      ['38400', "38400"],
      ['57600', "57600"],
      ['115200', "115200"],
    ]),"serialbegins")
  this.setPreviousStatement(true,null);
   this.setNextStatement(true,null);
  this.setTooltip('');
  }
  };
  //串口打印字符不换行
  Blockly.Blocks.ph_serialprintstring = {
  init:function(){
  this.setColour(color_serial);
  this.appendDummyInput("")
    .appendField(Blockly.Msg.PH_BAUDRATE)
      .appendField(new Blockly.FieldDropdown([
    ['Serial', "Serial"],
    ['softwareSerial', "softwareSerial"],
  ]),"SerialS22")
  .appendField(Blockly.Msg.PH_SERIALPRINTSTRINGS)
     this.appendValueInput("serialprints1", String)
  this.setPreviousStatement(true,null);
   this.setNextStatement(true,null);
  this.setTooltip('');
  }
  };
  //串口打印字符
  Blockly.Blocks.ph_serialprint = {
  init:function(){
  this.setColour(color_serial);
  this.appendDummyInput("")
    .appendField(Blockly.Msg.PH_BAUDRATE)
      .appendField(new Blockly.FieldDropdown([
    ['Serial', "Serial"],
    ['softwareSerial', "softwareSerial"],
  ]),"SerialS2")
  .appendField(Blockly.Msg.PH_SERIALPRINTSTRING)
     this.appendValueInput("serialprints", String)
  this.setPreviousStatement(true,null);
   this.setNextStatement(true,null);
  this.setTooltip('');
  }
  };
  //串口打印数字不换行
  Blockly.Blocks.ph_serialprintnum1 = {
  init:function(){
  this.setColour(color_serial);
  this.appendDummyInput("")
    .appendField(Blockly.Msg.PH_BAUDRATE)
      .appendField(new Blockly.FieldDropdown([
    ['Serial', "Serial"],
    ['softwareSerial', "softwareSerial"],
  ]),"SerialS33")
  .appendField(Blockly.Msg.PH_SERIALPRINTNUMBERS)
     this.appendValueInput("serialprintsss", Number)
  this.setPreviousStatement(true,null);
   this.setNextStatement(true,null);
  this.setTooltip('');
  }
  };



  //串口打印数字
  Blockly.Blocks.ph_serialprintnum = {
  init:function(){
  this.setColour(color_serial);
  this.appendDummyInput("")
    .appendField(Blockly.Msg.PH_BAUDRATE)
      .appendField(new Blockly.FieldDropdown([
    ['Serial', "Serial"],
    ['softwareSerial', "softwareSerial"],
  ]),"SerialS3")
  .appendField(Blockly.Msg.PH_SERIALPRINTNUMBER)
     this.appendValueInput("serialprintss", Number)
  this.setPreviousStatement(true,null);
   this.setNextStatement(true,null);
  this.setTooltip('');
  }
  };
  //串口打印16进制
  Blockly.Blocks.ph_serialprint16num = {
  init:function(){
  this.setColour(color_serial);
  this.appendDummyInput("")
     .appendField(Blockly.Msg.PH_BAUDRATE)
       .appendField(new Blockly.FieldDropdown([
    ['Serial', "Serial"],
    ['softwareSerial', "softwareSerial"],
  ]),"SerialS4")
  .appendField(Blockly.Msg.PH_SERIALPRINTHEX)
      this.appendValueInput("serialprint16nums", Number)
  this.setPreviousStatement(true,null);
    this.setNextStatement(true,null);
  this.setTooltip('');
  }
  };
  
  



  //串口有数据可读
  Blockly.Blocks.ph_serialava = {
    init:function(){
    this.setColour(color_serial);
    this.appendDummyInput("")
    .appendField(Blockly.Msg.PH_PORT)
    .appendField(new Blockly.FieldDropdown([
      ['Serial', "Serial"],
      ['softwareSerial', "softwareSerial"],
    ]),"SerialS")
      .appendField(Blockly.Msg.PH_SERIALAVALIBLE)
       this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
    this.setOutput(true, 'Boolean');
    this.setTooltip('');
    }
    };
    //串口读取字节
    Blockly.Blocks.ph_serialread = {
    init:function(){
    this.setColour(color_serial);
    this.appendDummyInput("")
    .appendField(Blockly.Msg.PH_PORT)
    .appendField(new Blockly.FieldDropdown([
      ['Serial', "Serial"],
      ['softwareSerial', "softwareSerial"],
    ]),"Serials")
       .appendField(Blockly.Msg.PH_SERIALREAD)
        this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
     this.setOutput(true, 'Number');
    this.setTooltip('');
    }
    };
    //串口读取整数小数
    Blockly.Blocks.ph_serialreadint = {
    init:function(){
    this.setColour(color_serial);
    this.appendDummyInput("")
    .appendField(Blockly.Msg.PH_PORT)
    .appendField(new Blockly.FieldDropdown([
      ['Serial', "Serial"],
      ['softwareSerial', "softwareSerial"],
    ]),"Serials9")
       .appendField(Blockly.Msg.PH_SERIALREADINTS)
       .appendField(new Blockly.FieldDropdown([
         [Blockly.Msg.PH_SERIALREADINT, "parseInt()"],
         [Blockly.Msg.PH_SERIALREADFLOAT, "parseFloat"],
       ]),"intfloat")
        this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
     this.setOutput(true, 'Number');
    this.setTooltip('');
    }
    };

    //软串口
  Blockly.Blocks.ph_softserial = {
    init:function(){
    this.setColour(color_serial);
    this.appendDummyInput("")
      .appendField(Blockly.Msg.PH_SOFTSERIAL_TX)
      .appendField(new Blockly.FieldDropdown([
        ['2', "2"],
        ['3', "3"],
        ['4', "4"],
        ['5', "5"],
        ['6', "6"],
        ['7', "7"],
        ['8', "8"],
        ['9', "9"],
        ['10', "10"],
        ['11', "11"],
        ['12', "12"],
        ['13', "13"],
        ['A0', "A0"],
        ['A1', "A1"],
        ['A2', "A2"],
        ['A3', "A3"],
        ['A4', "A4"],
        ['A5', "A5"],
      ]),"TX1")
      .appendField(Blockly.Msg.PH_SOFTSERIAL_RX)
      .appendField(new Blockly.FieldDropdown([
        ['2', "2"],
        ['3', "3"],
        ['4', "4"],
        ['5', "5"],
        ['6', "6"],
        ['7', "7"],
        ['8', "8"],
        ['9', "9"],
        ['10', "10"],
        ['11', "11"],
        ['12', "12"],
        ['13', "13"],
        ['A0', "A0"],
        ['A1', "A1"],
        ['A2', "A2"],
        ['A3', "A3"],
        ['A4', "A4"],
        ['A5', "A5"],
      ]),"RX1")
      .appendField(Blockly.Msg.PH_SOFTSERIALBAUDRATE)
      this.setPreviousStatement(true,null);
       this.setNextStatement(true,null);
      this.setTooltip('');
      }
      };
      //串口中断
    Blockly.Blocks.ph_serial_event = {
    init:function(){
    this.setColour(color_serial);
    this.appendDummyInput("")
    .appendField(Blockly.Msg.PH_PORT)
    .appendField(new Blockly.FieldDropdown([
      ['Serial', "Serial"],
      ['softwareSerial', "softwareSerial"],
    ]),"Serials")
    .appendField(Blockly.Msg.PH_INTERRUPUT);
       this.appendStatementInput('DO')
                .appendField(Blockly.Msg.PH_DO);
            this.setPreviousStatement(true);
            this.setNextStatement(true);
            this.setTooltip('');
    }
    };
    //串口清空缓存区数据
    Blockly.Blocks.ph_serial_flush = {
    init:function(){
    this.setColour(color_serial);
    this.appendDummyInput("")
    .appendField(Blockly.Msg.PH_PORT)
    .appendField(new Blockly.FieldDropdown([
      ['Serial', "Serial"],
      ['softwareSerial', "softwareSerial"],
    ]),"Serials")
    .appendField(Blockly.Msg.PH_FLUSH);
            this.setPreviousStatement(true);
            this.setNextStatement(true);
            this.setTooltip('');
    }
    };
    //串口读取字符串
    Blockly.Blocks.ph_serial_read = {
    init:function(){
    this.setColour(color_serial);
    this.appendDummyInput("")
    .appendField(Blockly.Msg.PH_PORT)
    .appendField(new Blockly.FieldDropdown([
      ['Serial', "Serial"],
      ['softwareSerial', "softwareSerial"],
    ]),"Serials")
      .appendField(Blockly.Msg.PH_READSTRING)
      this.appendValueInput("serialprints2", String)
           this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
        this.setOutput(true);
    this.setTooltip('');
    }
    };
  
  //rgb超声波模块初始化
Blockly.Blocks.ph_rgbUltrasonicInit = {
  init:function(){
   this.setColour(color_sensor);
   this.appendDummyInput("")
   .appendField(new Blockly.FieldImage(staticImg+"/52.RGB ultrasonic Module.svg", 84, 42))
    .appendField(Blockly.Msg.PH_ULTRASONICPIN)
       .appendField(new Blockly.FieldDropdown([
         ['P5', "P5"],
         ['P6', "P6"],
         ['P7', "P7"],
         ['P8', "P8"],
       ]),"ph_ulPINS")
       this.appendDummyInput("")
   this.setPreviousStatement(true,null);
     this.setNextStatement(true,null);
   this.setTooltip('');
  }
  };
//rgb超声波模块设置颜色样式
Blockly.Blocks.ph_rgbultrasonicsetcolorstyle = {
  init:function(){
   this.setColour(color_sensor);
   this.appendDummyInput("")
   .appendField(new Blockly.FieldImage(staticImg+"/52.RGB ultrasonic Module.svg", 84, 42))
      .appendField(Blockly.Msg.PH_RGBULTRASONICSETCOLOR)
       .appendField(new Blockly.FieldDropdown([
         [Blockly.Msg.PH_ALL, "E_RGB_ALL"],
         [Blockly.Msg.PH_LEFT, "E_RGB_LEFT"],
         [Blockly.Msg.PH_RIGHT, "E_RGB_RIGHT"],
       ]),"ph_rgbultrasonicposition")
       this.appendDummyInput("")
       .appendField(Blockly.Msg.PH_RGBULTRASONICSETCOLORLED)
       this.appendValueInput("COLOR", Number)
      this.appendDummyInput("")
      .appendField(Blockly.Msg.PH_RGBULTRASONICSTYLE)
           .appendField(new Blockly.FieldDropdown([
       [Blockly.Msg.PH_NONE, "E_EFFECT_NONE"],
         [Blockly.Msg.PH_BREATHING, "E_EFFECT_BREATHING"],
         [Blockly.Msg.PH_ROTATE, "E_EFFECT_ROTATE"],
         [Blockly.Msg.PH_FLASH, "E_EFFECT_FLASH"],
       ]),"ph_rgbultrasoniccolorstyle")
   this.setPreviousStatement(true,null);
     this.setNextStatement(true,null);
   this.setTooltip('');
  }
  };
  //RGB超声波模块读取超声波距离
  Blockly.Blocks.ph_rgbultrasonicreaddistance = {
  init:function(){
  this.setColour(color_sensor);
  this.appendDummyInput("")
  .appendField(new Blockly.FieldImage(staticImg+"/52.RGB ultrasonic Module.svg", 84, 42))
    .appendField(Blockly.Msg.PH_RGBULTRASONICREADDISTANCE)
        this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
     this.setOutput(true, 'Number');
    this.setTooltip('');
  }
  };

//4x4矩阵键盘初始化
Blockly.Blocks.ph_matrixKeyboardInit = {
  init:function(){
   this.setColour(base_color);
   this.appendDummyInput("")
   .appendField(new Blockly.FieldImage(staticImg+"/49.Matrix Keyboard Module.svg", 84, 42))
      .appendField(Blockly.Msg.PH_MATRIXKEYBOARDINIT)
      .appendField(new Blockly.FieldDropdown([
         ['P5', "P5"],
         ['P6', "P6"],
         ['P7', "P7"],
         ['P8', "P8"],
      ]),"matrixKeyBoardPort")
   this.setPreviousStatement(true,null);
     this.setNextStatement(true,null);
   this.setTooltip('');
  }
};

//4x4矩阵键盘
Blockly.Blocks.ph_matrixKeyboardFunc = {
  init:function(){
   this.setColour(base_color);
   this.appendDummyInput("")
   .appendField(new Blockly.FieldImage(staticImg+"/49.Matrix Keyboard Module.svg", 84, 42))
      .appendField(Blockly.Msg.PH_BUTTONPUSHED)
      .appendField(new Blockly.FieldDropdown([
        [Blockly.Msg.PH_KEYA, "A"],
        [Blockly.Msg.PH_KEYB, "B"],
        [Blockly.Msg.PH_KEYC, "C"],
        [Blockly.Msg.PH_KEYD, "D"],
        [Blockly.Msg.PH_KEYSTAR, "*"],
        [Blockly.Msg.PH_KEYAHASHTAG, "#"],
        [Blockly.Msg.PH_KEY1, "1"],
        [Blockly.Msg.PH_KEY2, "2"],
        [Blockly.Msg.PH_KEY3, "3"],
        [Blockly.Msg.PH_KEY4, "4"],
        [Blockly.Msg.PH_KEY5, "5"],
        [Blockly.Msg.PH_KEY6, "6"],
        [Blockly.Msg.PH_KEY7, "7"],
        [Blockly.Msg.PH_KEY8, "8"],
        [Blockly.Msg.PH_KEY9, "9"],
        [Blockly.Msg.PH_KEY0, "0"],
      ]),"ph_keyBoardValue")
      .appendField(Blockly.Msg.PH_STATUS)
      .appendField(new Blockly.FieldDropdown([
        [Blockly.Msg.PH_PRESS, "press"],
        [Blockly.Msg.PH_RELEASE, "release"],
        [Blockly.Msg.PH_LONGPRESS, "holdDown"],
      ]),"ph_keyBoardCorrespondValue")  
      this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
      this.setOutput(true, 'Boolean');
      this.setTooltip('');
  }
};

//获取矩阵键盘的值
Blockly.Blocks.ph_getMatrixKeyboardValue = {
  init:function(){
  this.setColour(base_color);
  this.appendDummyInput("")
  .appendField(new Blockly.FieldImage(staticImg+"/49.Matrix Keyboard Module.svg", 84, 42))
    .appendField(Blockly.Msg.PH_GETMATRIXKEYBOARDVALUE)
        this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
     this.setOutput(true, 'String');
    this.setTooltip('');
  }
};

//初始化ds1302  
Blockly.Blocks.ph_initds1302 = {
  init:function(){
  this.setColour(color_sensor);
  this.appendDummyInput("")
  .appendField(new Blockly.FieldImage(staticImg+"/Clock Module.svg", 84, 42))
    .appendField(Blockly.Msg.PH_DSINIT_RSTPIN)
     .appendField(new Blockly.FieldDropdown([
       ['P15', "P15"],
       ['P16', "P16"],
     ]),"ds1302Port")
      this.setPreviousStatement(true,null);
      this.setNextStatement(true,null);
  this.setTooltip('');
  }
  };

  //ds1302设置时分秒
  Blockly.Blocks.ph_setds1302time = {
  init:function(){
  this.setColour(color_sensor);
  this.appendDummyInput("")
  .appendField(new Blockly.FieldImage(staticImg+"/Clock Module.svg", 84, 42))
    .appendField(Blockly.Msg.PH_DSSETTIME)
     this.appendValueInput("hour", Number)
     .appendField(Blockly.Msg.PH_GETHOUR)
     this.appendValueInput("minute", Number)
     .appendField(Blockly.Msg.PH_GETMINUTE)
     this.appendValueInput("second", Number)
     .appendField(Blockly.Msg.PH_GETSECOND)
  this.setPreviousStatement(true,null);
   this.setNextStatement(true,null);
  this.setTooltip('');
  }
  };
  //ds1302设置年月日
  Blockly.Blocks.ph_setds1302date = {
    init:function(){
    this.setColour(color_sensor);
    this.appendDummyInput("")
    .appendField(new Blockly.FieldImage(staticImg+"/Clock Module.svg", 84, 42))
      .appendField(Blockly.Msg.PH_DSSETDATE)
      this.appendValueInput("year", Number)
      .appendField(Blockly.Msg.PH_GETYEAR)
      this.appendValueInput("month", Number)
      .appendField(Blockly.Msg.PH_GETMONTH)
      this.appendValueInput("day", Number)
      .appendField(Blockly.Msg.PH_GETDAY)
    this.setPreviousStatement(true,null);
    this.setNextStatement(true,null);
    this.setTooltip('');
    }
  };

   //获取ds1302年月日时分秒
Blockly.Blocks.ph_getds1302date = {
  init:function(){
  this.setColour(color_sensor);
  this.appendDummyInput("")
  .appendField(new Blockly.FieldImage(staticImg+"/Clock Module.svg", 84, 42))
    .appendField(Blockly.Msg.PH_DSGETDATE)
      .appendField(new Blockly.FieldDropdown([
        [Blockly.Msg.PH_GETYEAR, "getYear"],
        [Blockly.Msg.PH_GETMONTH, "getMonthStr"],
        [Blockly.Msg.PH_GETDAY, "getDay"],
        [Blockly.Msg.PH_GETHOUR, "getHour"],
        [Blockly.Msg.PH_GETMINUTE, "getMinute"],
      [Blockly.Msg.PH_GETSECOND, "getSecond"],
        [Blockly.Msg.PH_GETWEEK, "getDOWStr"],
      ]),"DATES")
        this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
     this.setOutput(true, 'Number');
    this.setTooltip('');
  }
  };

/*/光敏传感器
lockly.Blocks.ph_light = {
init:function(){
  this.setColour("#00B1AC");
  this.appendDummyInput("")
    .appendField(Blockly.Msg.PH_LIGHT)
    .appendField(new Blockly.FieldDropdown([
      ['P1', "A0"],
      ['P2', "A1"],
      ['P3', "A2"],
      ['P4', "A3"],
      ['P5', "A4"],
      ['P6', "A5"],
    ]),"phlight")
      .appendField(Blockly.Msg.PH_READLIGHT)
this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
    this.setOutput(true, 'Number');
  this.setTooltip('');
}
};*/
      /*悍马初始化
      Blockly.Blocks.hb_setup = {
        init:function(){
        this.setColour("#00B1AC");
        this.appendDummyInput("")
		//.appendField(new Blockly.FieldImage(staticImg+"/xxx.jpg", 45, 38))
            .appendField(Blockly.Msg.HUMMERBOT_SETUP)
        this.setPreviousStatement(true,null);
          this.setNextStatement(true,null);
        this.setTooltip('');
        }
      };
 //电机引脚
          Blockly.Blocks.hb_motor = {
            init:function(){
              this.setColour("#00B1AC");
              this.appendDummyInput("")
                .appendField(Blockly.Msg.HUMMERBOT_MOTORPINS)
				 this.appendDummyInput("")
                .appendField(Blockly.Msg.HUMMERBOT_LNPINS)
                 .appendField(new Blockly.FieldDropdown([
                      ['3', "3"],
                      ['5', "5"],
                      ['6', "6"],
                      ['9', "9"],
                      ['10', "10"],
                      ['11', "11"],
      ]),"LNPINS")
	                  .appendField(Blockly.Msg.HUMMERBOT_LPPINS)
                 .appendField(new Blockly.FieldDropdown([
                      ['3', "3"],
                      ['5', "5"],
                      ['6', "6"],
                      ['9', "9"],
                      ['10', "10"],
                      ['11', "11"],
      ]),"LPPINS")
	                  .appendField(Blockly.Msg.HUMMERBOT_RNPINS)
                 .appendField(new Blockly.FieldDropdown([
                      ['3', "3"],
                      ['5', "5"],
                      ['6', "6"],
                      ['9', "9"],
                      ['10', "10"],
                      ['11', "11"],
      ]),"RNPINS")
	                  .appendField(Blockly.Msg.HUMMERBOT_RPPINS)
                 .appendField(new Blockly.FieldDropdown([
                      ['3', "3"],
                      ['5', "5"],
                      ['6', "6"],
                      ['9', "9"],
                      ['10', "10"],
                      ['11', "11"],
      ]),"RPPINS")
              this.setPreviousStatement(true,null);
            this.setNextStatement(true,null);
          this.setTooltip('');
            }
            };
      //小车行驶方向下拉（下拉没有value），速度（输入,有value）
      Blockly.Blocks.hb_move = {
        init:function(){
          this.setColour("#00B1AC");
          this.appendDummyInput("")
            .appendField(Blockly.Msg.HUMMERBOT_HUMMERBOT)
              .appendField(new Blockly.FieldDropdown([
                [Blockly.Msg.HUMMERBOT_GOFORWARD, "1"],
                [Blockly.Msg.HUMMERBOT_GOBACK, "2"],
                [Blockly.Msg.HUMMERBOT_TURNLEFT, "3"],
                [Blockly.Msg.HUMMERBOT_TURNRIGHT, "4"],
                [Blockly.Msg.HUMMERBOT_KEEPSTOP, "5"],
              ]),"DIRECTIONS")
			  .appendField(Blockly.Msg.HUMMERBOT_SPEED)
              this.appendValueInput("Speed", Number)
          this.setPreviousStatement(true,null);
            this.setNextStatement(true,null);
          this.setTooltip('');
        }
        };

      //舵机校准角度
        Blockly.Blocks.hb_servo = {
          init:function(){
          this.setColour("#00B1AC");
          this.appendDummyInput("")
              .appendField(Blockly.Msg.HUMMERBOT_SERVOPIN)
              .appendField(new Blockly.FieldDropdown([
                ['0', "0"],
                  ['1', "1"],
                  ['2', "2"],
                  ['3', "3"],
                  ['4', "4"],
                  ['5', "5"],
                  ['6', "6"],
                  ['7', "7"],
                  ['8', "8"],
                  ['9', "9"],
                  ['10', "10"],
                  ['11', "11"],
                  ['12', "12"],
                  ['13', "13"],
                  ['A0', "A0"],
                  ['A1', "A1"],
                  ['A2', "A2"],
                  ['A3', "A3"],
                  ['A4', "A4"],
                  ['A5', "A5"],
                ]),"SERVOPINS")
				.appendField(Blockly.Msg.HUMMERBOT_SERVOSTANDARDDEGREE)
              this.appendValueInput("StandardServoDegree", Number)
          this.setPreviousStatement(true,null);
            this.setNextStatement(true,null);
          this.setTooltip('');
          }
        };



      //设置舵机角度
 Blockly.Blocks.hb_servodegree = {
          init:function(){
          this.setColour("#00B1AC");
          this.appendDummyInput("")
              .appendField(Blockly.Msg.HUMMERBOT_SERVODEGREE)
              this.appendValueInput("servodegree", Number)
          this.setPreviousStatement(true,null);
            this.setNextStatement(true,null);
          this.setTooltip('');
          }
        };

      //转弯角度，速度
      Blockly.Blocks.hb_turn = {
      init:function(){
        this.setColour("#00B1AC");
        this.appendDummyInput("")
          .appendField(Blockly.Msg.HUMMERBOT_TURNANGLE)
            this.appendValueInput("TurnAngle", Number)
			 this.appendDummyInput("")
			.appendField(Blockly.Msg.HUMMERBOT_TURNSPEED)
            this.appendValueInput("TurnSpeed", Number)
        this.setPreviousStatement(true,null);
          this.setNextStatement(true,null);
        this.setTooltip('');
      }
      };
      //加速
      Blockly.Blocks.hb_speedup = {
      init:function(){
        this.setColour("#00B1AC");
        this.appendDummyInput("")
          .appendField(Blockly.Msg.HUMMERBOT_SPEEDUP)
        this.setPreviousStatement(true,null);
          this.setNextStatement(true,null);
        this.setTooltip('');
      }
      };
	   //减速
      Blockly.Blocks.hb_speeddown = {
      init:function(){
        this.setColour("#00B1AC");
        this.appendDummyInput("")
          .appendField(Blockly.Msg.HUMMERBOT_SPEEDDOWN)
        this.setPreviousStatement(true,null);
          this.setNextStatement(true,null);
        this.setTooltip('');
      }
      };
	 //获取当前速度
      Blockly.Blocks.hb_getcurrentspeed = {
      init:function(){
        this.setColour("#00B1AC");
        this.appendDummyInput("")
          .appendField(Blockly.Msg.HUMMERBOT_GETCURRENTSPEED)
  this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
          this.setOutput(true, 'Number');
        this.setTooltip('');
      }
      };
	  //红外接收初始化
      Blockly.Blocks.hb_irReceiveInit = {
      init:function(){
        this.setColour("#00B1AC");
        this.appendDummyInput("")
          .appendField(Blockly.Msg.HUMMERBOT_IRRECEIVEINIT)
        this.setPreviousStatement(true,null);
          this.setNextStatement(true,null);
        this.setTooltip('');
      }
      };
	  //红外遥控器按键被按下？
      Blockly.Blocks.hb_irKeyPressed = {
      init:function(){
        this.setColour("#00B1AC");
        this.appendDummyInput("")
          .appendField(Blockly.Msg.HUMMERBOT_IRKEYPRESSED)
            this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
        this.setOutput(true, 'Boolean');
        this.setTooltip('');
      }
      };
	 //红外遥控器的什么键被按下？
      Blockly.Blocks.hb_irKeyPress = {
      init:function(){
        this.setColour("#00B1AC");
        this.appendDummyInput("")
          .appendField(Blockly.Msg.HUMMERBOT_IRKEYPRESS)
		                   .appendField(new Blockly.FieldDropdown([
                      ['1', "EM_IR_KEYCODE_1"],
                      ['2', "EM_IR_KEYCODE_2"],
                      ['3', "EM_IR_KEYCODE_3"],
                      ['4', "EM_IR_KEYCODE_4"],
                      ['5', "EM_IR_KEYCODE_5"],
                      ['6', "EM_IR_KEYCODE_6"],
                      ['7', "EM_IR_KEYCODE_7"],
                      ['8', "EM_IR_KEYCODE_8"],
                      ['9', "EM_IR_KEYCODE_9"],
                      ['0', "EM_IR_KEYCODE_0"],
                      ['A', "EM_IR_KEYCODE_A"],
                      ['B', "EM_IR_KEYCODE_B"],
                      ['C', "EM_IR_KEYCODE_C"],
                      ['D', "EM_IR_KEYCODE_D"],
                      ['+', "EM_IR_KEYCODE_PLUS"],
                      ['-', "EM_IR_KEYCODE_REDUCE"],
                      ['↑', "EM_IR_KEYCODE_UP"],
                      ['↓', "EM_IR_KEYCODE_DOWN"],
                      ['OK', "EM_IR_KEYCODE_OK"],
                      ['←', "EM_IR_KEYCODE_LEFT"],
                      ['→', "EM_IR_KEYCODE_RIGHT"],
      ]),"IRKEYS")
            this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
        this.setOutput(true, 'Boolean');
        this.setTooltip('');
      }
      };
	  //rgb超声波模块引脚
	          Blockly.Blocks.hb_ultrasonicpin = {
          init:function(){
          this.setColour("#00B1AC");
          this.appendDummyInput("")
              .appendField(Blockly.Msg.HUMMERBOT_ULTRASONIC)
			   this.appendDummyInput("")
              .appendField(Blockly.Msg.HUMMERBOT_ULTRASONICPIN)
              .appendField(new Blockly.FieldDropdown([
                ['0', "0"],
                  ['1', "1"],
                  ['2', "2"],
                  ['3', "3"],
                  ['4', "4"],
                  ['5', "5"],
                  ['6', "6"],
                  ['7', "7"],
                  ['8', "8"],
                  ['9', "9"],
                  ['10', "10"],
                  ['11', "11"],
                  ['12', "12"],
                  ['13', "13"],
                  ['A0', "A0"],
                  ['A1', "A1"],
                  ['A2', "A2"],
                  ['A3', "A3"],
                  ['A4', "A4"],
                  ['A5', "A5"],
                ]),"ULTRASONICPINS")
				.appendField(Blockly.Msg.HUMMERBOT_RGBPIN)
              .appendField(new Blockly.FieldDropdown([
                ['0', "0"],
                  ['1', "1"],
                  ['2', "2"],
                  ['3', "3"],
                  ['4', "4"],
                  ['5', "5"],
                  ['6', "6"],
                  ['7', "7"],
                  ['8', "8"],
                  ['9', "9"],
                  ['10', "10"],
                  ['11', "11"],
                  ['12', "12"],
                  ['13', "13"],
                  ['A0', "A0"],
                  ['A1', "A1"],
                  ['A2', "A2"],
                  ['A3', "A3"],
                  ['A4', "A4"],
                  ['A5', "A5"],
                ]),"RGBPINS")
          this.setPreviousStatement(true,null);
            this.setNextStatement(true,null);
          this.setTooltip('');
          }
        };

	//读取超声波距离
		 Blockly.Blocks.hb_readUltrasonicDistance = {
      init:function(){
        this.setColour("#00B1AC");
        this.appendDummyInput("")
          .appendField(Blockly.Msg.HUMMERBOT_READULTRASONICDISTANCE)
		                   .appendField(new Blockly.FieldDropdown([
                      [Blockly.Msg.HUMMERBOT_READULTRASONICFRONTDISTANCE, "0"],
                      [Blockly.Msg.HUMMERBOT_READULTRASONICLEFTDISTANCE, "1"],
                      [Blockly.Msg.HUMMERBOT_READULTRASONICRIGHTDISTANCE, "2"],
      ]),"ULTRASONICDITANCES")
        this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
          this.setOutput(true, 'Number');
        this.setTooltip('');
      }
      };


	  //设置rgb的颜色
	   Blockly.Blocks.hb_RGB = {
          init:function(){
          this.setColour("#00B1AC");
          this.appendDummyInput("")
              .appendField(Blockly.Msg.HUMMERBOT_RGB)
              .appendField(new Blockly.FieldDropdown([
                 [Blockly.Msg.HUMMERBOT_RGBALL, "0"],
                  [Blockly.Msg.HUMMERBOT_RGBLEFT, "1"],
                  [Blockly.Msg.HUMMERBOT_RGBRIGHT, "2"],
                ]),"RGB")
				.appendField(Blockly.Msg.HUMMERBOT_RGBCOLOR)
              .appendField(new Blockly.FieldDropdown([
                [Blockly.Msg.HUMMERBOT_RGBCOLORRED, "0xFF0000"],
                [Blockly.Msg.HUMMERBOT_RGBCOLORGREEN, "0x00FF00"],
                [Blockly.Msg.HUMMERBOT_RGBCOLORBLUE, "0x0000FF"],
                [Blockly.Msg.HUMMERBOT_RGBCOLORYELLOW, "0xFFFF00"],
                [Blockly.Msg.HUMMERBOT_RGBCOLORPURPLE, "0xFF00FF"],
                [Blockly.Msg.HUMMERBOT_RGBCOLORWHITE, "0xFFFFFF"],
                [Blockly.Msg.HUMMERBOT_RGBCOLORBLACK, "0x000000"],
                ]),"RGBCOLORS")
			  .appendField(Blockly.Msg.HUMMERBOT_RGBCOLORSTYLE)
              .appendField(new Blockly.FieldDropdown([
                [Blockly.Msg.HUMMERBOT_RGBNONE, "3"],
                [Blockly.Msg.HUMMERBOT_RGBBREATHE, "0"],
                [Blockly.Msg.HUMMERBOT_RGBROTATE, "1"],
                [Blockly.Msg.HUMMERBOT_RGBFLASH, "2"],
                ]),"RGBCOLORSstyle")
          this.setPreviousStatement(true,null);
            this.setNextStatement(true,null);
          this.setTooltip('');
          }
        };
		//红外避障引脚
		 Blockly.Blocks.hb_irAvoidance = {
          init:function(){
          this.setColour("#00B1AC");
          this.appendDummyInput("")
              .appendField(Blockly.Msg.HUMMERBOT_IRAVOIDANCE)
			   this.appendDummyInput("")
              .appendField(Blockly.Msg.HUMMERBOT_IRAVOIDANCELEFTPIN)
              .appendField(new Blockly.FieldDropdown([
                ['0', "0"],
                  ['1', "1"],
                  ['2', "2"],
                  ['3', "3"],
                  ['4', "4"],
                  ['5', "5"],
                  ['6', "6"],
                  ['7', "7"],
                  ['8', "8"],
                  ['9', "9"],
                  ['10', "10"],
                  ['11', "11"],
                  ['12', "12"],
                  ['13', "13"],
                  ['A0', "A0"],
                  ['A1', "A1"],
                  ['A2', "A2"],
                  ['A3', "A3"],
                  ['A4', "A4"],
                  ['A5', "A5"],
                ]),"IRAVOIDANCELEFTPINS")
				.appendField(Blockly.Msg.HUMMERBOT_IRAVOIDANCERIGHTPIN)
              .appendField(new Blockly.FieldDropdown([
                ['0', "0"],
                  ['1', "1"],
                  ['2', "2"],
                  ['3', "3"],
                  ['4', "4"],
                  ['5', "5"],
                  ['6', "6"],
                  ['7', "7"],
                  ['8', "8"],
                  ['9', "9"],
                  ['10', "10"],
                  ['11', "11"],
                  ['12', "12"],
                  ['13', "13"],
                  ['A0', "A0"],
                  ['A1', "A1"],
                  ['A2', "A2"],
                  ['A3', "A3"],
                  ['A4', "A4"],
                  ['A5', "A5"],
                ]),"IRAVOIDANCERIGHTPINS")
          this.setPreviousStatement(true,null);
            this.setNextStatement(true,null);
          this.setTooltip('');
          }
        };
		//检测障碍物

				 Blockly.Blocks.hb_readIrAvoidanceDistance = {
      init:function(){
        this.setColour("#00B1AC");
        this.appendDummyInput("")
          .appendField(Blockly.Msg.HUMMERBOT_READIRAVOIDANCEDISTANCE)
		                   .appendField(new Blockly.FieldDropdown([
					  [Blockly.Msg.HUMMERBOT_READIRAVOIDANCEDISTANCENO, "IOA_ALL_NO"],
                      [Blockly.Msg.HUMMERBOT_READIRAVOIDANCEDISTANCEYES, "IOA_ALL_YES"],
                      [Blockly.Msg.HUMMERBOT_READIRAVOIDANCEDISTANCELEFT, "IOA_LEFT"],
                      [Blockly.Msg.HUMMERBOT_READIRAVOIDANCEDISTANCERIGHT, "IOA_RIGHT"],
      ]),"IRAVOIDANCEDITANCES")
        this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
          this.setOutput(true, 'Boolean');
        this.setTooltip('');
      }
      };

	  //读取红外避障值

				 Blockly.Blocks.hb_readIrAvoidanceDistances = {
      init:function(){
        this.setColour("#00B1AC");
        this.appendDummyInput("")
          .appendField(Blockly.Msg.HUMMERBOT_READIRAVOIDANCEDISTANCES)
		                   .appendField(new Blockly.FieldDropdown([
                      [Blockly.Msg.HUMMERBOT_READIRAVOIDANCEDISTANCELEFTS, "0"],
                      [Blockly.Msg.HUMMERBOT_READIRAVOIDANCEDISTANCERIGHTS, "1"],
      ]),"IRAVOIDANCEDITANCESS")
        this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
          this.setOutput(true, 'Number');
        this.setTooltip('');
      }
      };
	  //追光模块引脚
		 Blockly.Blocks.hb_photosensitivePin = {
          init:function(){
          this.setColour("#00B1AC");
          this.appendDummyInput("")
              .appendField(Blockly.Msg.HUMMERBOT_PHOTOSENSITIVE)
			   this.appendDummyInput("")
              .appendField(Blockly.Msg.HUMMERBOT_PHOTOSENSITIVELEFTPIN)
              .appendField(new Blockly.FieldDropdown([
                ['0', "0"],
                  ['1', "1"],
                  ['2', "2"],
                  ['3', "3"],
                  ['4', "4"],
                  ['5', "5"],
                  ['6', "6"],
                  ['7', "7"],
                  ['8', "8"],
                  ['9', "9"],
                  ['10', "10"],
                  ['11', "11"],
                  ['12', "12"],
                  ['13', "13"],
                  ['A0', "A0"],
                  ['A1', "A1"],
                  ['A2', "A2"],
                  ['A3', "A3"],
                  ['A4', "A4"],
                  ['A5', "A5"],
                ]),"PHOTOSENSITIVELEFTPINS")
				.appendField(Blockly.Msg.HUMMERBOT_PHOTOSENSITIVERIGHTPIN)
              .appendField(new Blockly.FieldDropdown([
                ['0', "0"],
                  ['1', "1"],
                  ['2', "2"],
                  ['3', "3"],
                  ['4', "4"],
                  ['5', "5"],
                  ['6', "6"],
                  ['7', "7"],
                  ['8', "8"],
                  ['9', "9"],
                  ['10', "10"],
                  ['11', "11"],
                  ['12', "12"],
                  ['13', "13"],
                  ['A0', "A0"],
                  ['A1', "A1"],
                  ['A2', "A2"],
                  ['A3', "A3"],
                  ['A4', "A4"],
                  ['A5', "A5"],
                ]),"PHOTOSENSITIVERIGHTPINS")
          this.setPreviousStatement(true,null);
            this.setNextStatement(true,null);
          this.setTooltip('');
          }
        };

		//获取光线弱度值（值越大光越弱）
						 Blockly.Blocks.hb_getPhotosensitive = {
      init:function(){
        this.setColour("#00B1AC");
        this.appendDummyInput("")
          .appendField(Blockly.Msg.HUMMERBOT_GETPHOTOSENSITIVE)
		                   .appendField(new Blockly.FieldDropdown([
                      [Blockly.Msg.HUMMERBOT_GETPHOTOSENSITIVELEFT, "0"],
                      [Blockly.Msg.HUMMERBOT_GETPHOTOSENSITIVERIGHT, "1"],
      ]),"PHOTOSENSITIVEVALUE")
        this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
          this.setOutput(true, 'Number');
        this.setTooltip('');
      }
      };

	  //设置ps2引脚
	   Blockly.Blocks.hb_PS2Pin = {
          init:function(){
          this.setColour("#00B1AC");
          this.appendDummyInput("")
              .appendField(Blockly.Msg.HUMMERBOT_PS2)
			   this.appendDummyInput("")
              .appendField(Blockly.Msg.HUMMERBOT_PS2CLK)
              .appendField(new Blockly.FieldDropdown([
                ['0', "0"],
                  ['1', "1"],
                  ['2', "2"],
                  ['3', "3"],
                  ['4', "4"],
                  ['5', "5"],
                  ['6', "6"],
                  ['7', "7"],
                  ['8', "8"],
                  ['9', "9"],
                  ['10', "10"],
                  ['11', "11"],
                  ['12', "12"],
                  ['13', "13"],
                  ['A0', "A0"],
                  ['A1', "A1"],
                  ['A2', "A2"],
                  ['A3', "A3"],
                  ['A4', "A4"],
                  ['A5', "A5"],
                ]),"CLKPINS")
				.appendField(Blockly.Msg.HUMMERBOT_PS2CMD)
              .appendField(new Blockly.FieldDropdown([
                ['0', "0"],
                  ['1', "1"],
                  ['2', "2"],
                  ['3', "3"],
                  ['4', "4"],
                  ['5', "5"],
                  ['6', "6"],
                  ['7', "7"],
                  ['8', "8"],
                  ['9', "9"],
                  ['10', "10"],
                  ['11', "11"],
                  ['12', "12"],
                  ['13', "13"],
                  ['A0', "A0"],
                  ['A1', "A1"],
                  ['A2', "A2"],
                  ['A3', "A3"],
                  ['A4', "A4"],
                  ['A5', "A5"],
                ]),"CMDPINS")
				.appendField(Blockly.Msg.HUMMERBOT_PS2ATT)
              .appendField(new Blockly.FieldDropdown([
                ['0', "0"],
                  ['1', "1"],
                  ['2', "2"],
                  ['3', "3"],
                  ['4', "4"],
                  ['5', "5"],
                  ['6', "6"],
                  ['7', "7"],
                  ['8', "8"],
                  ['9', "9"],
                  ['10', "10"],
                  ['11', "11"],
                  ['12', "12"],
                  ['13', "13"],
                  ['A0', "A0"],
                  ['A1', "A1"],
                  ['A2', "A2"],
                  ['A3', "A3"],
                  ['A4', "A4"],
                  ['A5', "A5"],
                ]),"ATTPINS")
				.appendField(Blockly.Msg.HUMMERBOT_PS2DAT)
              .appendField(new Blockly.FieldDropdown([
                ['0', "0"],
                  ['1', "1"],
                  ['2', "2"],
                  ['3', "3"],
                  ['4', "4"],
                  ['5', "5"],
                  ['6', "6"],
                  ['7', "7"],
                  ['8', "8"],
                  ['9', "9"],
                  ['10', "10"],
                  ['11', "11"],
                  ['12', "12"],
                  ['13', "13"],
                  ['A0', "A0"],
                  ['A1', "A1"],
                  ['A2', "A2"],
                  ['A3', "A3"],
                  ['A4', "A4"],
                  ['A5', "A5"],
                ]),"DATPINS")
          this.setPreviousStatement(true,null);
            this.setNextStatement(true,null);
          this.setTooltip('');
          }
        };
		//ps2开始读取键值
		 Blockly.Blocks.hb_ps2ready = {
          init:function(){
          this.setColour("#00B1AC");
          this.appendDummyInput("")
              .appendField(Blockly.Msg.HUMMERBOT_PS2READY)
          this.setPreviousStatement(true,null);
            this.setNextStatement(true,null);
          this.setTooltip('');
          }
        };
		 //ps2按键被按下？
      Blockly.Blocks.hb_ps2KeyPressed = {
      init:function(){
        this.setColour("#00B1AC");
        this.appendDummyInput("")
          .appendField(Blockly.Msg.HUMMERBOT_PS2KEYPRESSED)
            this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
        this.setOutput(true, 'Boolean');
        this.setTooltip('');
      }
      };
	 //ps2的什么键被按下？
      Blockly.Blocks.hb_ps2KeyPress = {
      init:function(){
        this.setColour("#00B1AC");
        this.appendDummyInput("")
          .appendField(Blockly.Msg.HUMMERBOT_PS2KEYPRESS)
		                   .appendField(new Blockly.FieldDropdown([
                      ['↑', "PSB_PAD_UP"],
                      ['↓', "PSB_PAD_DOWN"],
                      ['←', "PSB_PAD_LEFT"],
                      ['→', "PSB_PAD_RIGHT"],
                      ['×', "PSB_CROSS"],
                      ['○', "PSB_CIRCLE"],
                      ['△', "PSB_TRIANGLE"],
                      ['□', "PSB_SQUARE"],
      ]),"PS2KEYS")
            this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
        this.setOutput(true, 'Boolean');
        this.setTooltip('');
      }
      };
//接收蓝牙数据
	 Blockly.Blocks.hb_receiveBluetoothData = {
          init:function(){
          this.setColour("#00B1AC");
          this.appendDummyInput("")
              .appendField(Blockly.Msg.HUMMERBOT_RECEIVEBLUETOOTHDATA)
          this.setPreviousStatement(true,null);
            this.setNextStatement(true,null);
          this.setTooltip('');
          }
        };
//接收到了蓝牙数据
      Blockly.Blocks.hb_receivedBluetoothData = {
      init:function(){
        this.setColour("#00B1AC");
        this.appendDummyInput("")
          .appendField(Blockly.Msg.HUMMERBOT_RECEIVEDBLUETOOTHDATA)
            this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
        this.setOutput(true, 'Boolean');
        this.setTooltip('');
      }
      };
//蓝牙数据类型是
      Blockly.Blocks.hb_bluetoothstyle = {
      init:function(){
        this.setColour("#00B1AC");
        this.appendDummyInput("")
          .appendField(Blockly.Msg.HUMMERBOT_BLUESTYLE)
		                   .appendField(new Blockly.FieldDropdown([
                      [Blockly.Msg.HUMMERBOT_BLUESTYLEBUTTON, "13"],
                      [Blockly.Msg.HUMMERBOT_BLUESTYLEDEGREE, "5"],
                      [Blockly.Msg.HUMMERBOT_BLUESTYLESPEED, "6"],
      ]),"BLUESTYLES")
            this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
        this.setOutput(true, 'Boolean');
        this.setTooltip('');
      }
      };
//蓝牙操作键按下
      Blockly.Blocks.hb_bluetoothKeyPressed = {
      init:function(){
        this.setColour("#00B1AC");
        this.appendDummyInput("")
          .appendField(Blockly.Msg.HUMMERBOT_BLUEKEYPRESS)
		                   .appendField(new Blockly.FieldDropdown([
                      ['↑', "0x0008"],
                      ['↓', "0x0020"],
                      ['←', "0x0010"],
                      ['→', "0x0004"],
                      ['+', "0x0040"],
                      ['-', "0x0080"],
					  ['red', "0x2000"],
                      ['pink', "0x8000"],
      ]),"BLUEKEYS")
            this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
        this.setOutput(true, 'Boolean');
        this.setTooltip('');
      }
      };
//蓝牙获取的角度
      Blockly.Blocks.hb_bluetoothgetdegree = {
        init:function(){
        this.setColour("#00B1AC");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.HUMMERBOT_BLUEGETDEGREE)
            this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
          this.setOutput(true, 'Number');
        this.setTooltip('');
        }
      };
//设置当前速度为蓝牙获取的速度
	 Blockly.Blocks.hb_bluetoothgetspeed = {
          init:function(){
          this.setColour("#00B1AC");
          this.appendDummyInput("")
              .appendField(Blockly.Msg.HUMMERBOT_BLUEGETSPEED)
          this.setPreviousStatement(true,null);
            this.setNextStatement(true,null);
          this.setTooltip('');
          }
        };
//红外循迹模块引脚
 Blockly.Blocks.hb_tracking = {
          init:function(){
          this.setColour("#00B1AC");
          this.appendDummyInput("")
              .appendField(Blockly.Msg.HUMMERBOT_TRACKING)
			   this.appendDummyInput("")
              .appendField(Blockly.Msg.HUMMERBOT_TRACKINGLEFT)
              .appendField(new Blockly.FieldDropdown([
                ['0', "0"],
                  ['1', "1"],
                  ['2', "2"],
                  ['3', "3"],
                  ['4', "4"],
                  ['5', "5"],
                  ['6', "6"],
                  ['7', "7"],
                  ['8', "8"],
                  ['9', "9"],
                  ['10', "10"],
                  ['11', "11"],
                  ['12', "12"],
                  ['13', "13"],
                  ['A0', "A0"],
                  ['A1', "A1"],
                  ['A2', "A2"],
                  ['A3', "A3"],
                  ['A4', "A4"],
                  ['A5', "A5"],
                ]),"TRACKINGLEFT")
				.appendField(Blockly.Msg.HUMMERBOT_TRACKINGMID)
              .appendField(new Blockly.FieldDropdown([
                ['0', "0"],
                  ['1', "1"],
                  ['2', "2"],
                  ['3', "3"],
                  ['4', "4"],
                  ['5', "5"],
                  ['6', "6"],
                  ['7', "7"],
                  ['8', "8"],
                  ['9', "9"],
                  ['10', "10"],
                  ['11', "11"],
                  ['12', "12"],
                  ['13', "13"],
                  ['A0', "A0"],
                  ['A1', "A1"],
                  ['A2', "A2"],
                  ['A3', "A3"],
                  ['A4', "A4"],
                  ['A5', "A5"],
                ]),"TRACKINGMID")
				.appendField(Blockly.Msg.HUMMERBOT_TRACKINGRIGHT)
              .appendField(new Blockly.FieldDropdown([
                ['0', "0"],
                  ['1', "1"],
                  ['2', "2"],
                  ['3', "3"],
                  ['4', "4"],
                  ['5', "5"],
                  ['6', "6"],
                  ['7', "7"],
                  ['8', "8"],
                  ['9', "9"],
                  ['10', "10"],
                  ['11', "11"],
                  ['12', "12"],
                  ['13', "13"],
                  ['A0', "A0"],
                  ['A1', "A1"],
                  ['A2', "A2"],
                  ['A3', "A3"],
                  ['A4', "A4"],
                  ['A5', "A5"],
                ]),"TRACKINGRIGHT")
          this.setPreviousStatement(true,null);
            this.setNextStatement(true,null);
          this.setTooltip('');
          }
        };
		//循迹状态是？
		Blockly.Blocks.hb_trackingstate = {
          init:function(){
          this.setColour("#00B1AC");
			   this.appendDummyInput("")
              .appendField(Blockly.Msg.HUMMERBOT_TRACKINGSTATE)
              .appendField(new Blockly.FieldDropdown([
                  [Blockly.Msg.HUMMERBOT_TRACKINGLEFTALLBLACK, "IT_ALL_BLACK"],
                  [Blockly.Msg.HUMMERBOT_TRACKINGLEFTALLWHITE, "IT_ALL_WHITE"],
                  [Blockly.Msg.HUMMERBOT_TRACKINGLEFTMID, "IT_CENTER"],
                  [Blockly.Msg.HUMMERBOT_TRACKINGLEFTRIGHT1, "IT_RIGHT1"],
                  [Blockly.Msg.HUMMERBOT_TRACKINGLEFTRIGHT2, "IT_RIGHT2"],
                  [Blockly.Msg.HUMMERBOT_TRACKINGLEFTLEFT1, "IT_LEFT1"],
                  [Blockly.Msg.HUMMERBOT_TRACKINGLEFTLEFT2, "IT_LEFT2"],
                ]),"TRACKINGSTATE")
             this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
        this.setOutput(true, 'Boolean');
        this.setTooltip('');
          }
        };
				//定义一个偏离黑线时的循迹状态变量
		Blockly.Blocks.hb_definetrackingold = {
          init:function(){
          this.setColour("#00B1AC");
			   this.appendDummyInput("")
              .appendField(Blockly.Msg.HUMMERBOT_DEFINETRACKINGSTATE)
     this.setPreviousStatement(true,null);
            this.setNextStatement(true,null);
          this.setTooltip('');
          }
        };
		//偏离黑线时的循迹状态是
					Blockly.Blocks.hb_trackingstateold = {
          init:function(){
          this.setColour("#00B1AC");
			   this.appendDummyInput("")
              .appendField(Blockly.Msg.HUMMERBOT_TRACKINGSTATEOLD)
              .appendField(new Blockly.FieldDropdown([
                  [Blockly.Msg.HUMMERBOT_TRACKINGLEFTRIGHT1, "IT_RIGHT1"],
                  [Blockly.Msg.HUMMERBOT_TRACKINGLEFTRIGHT2, "IT_RIGHT2"],
                  [Blockly.Msg.HUMMERBOT_TRACKINGLEFTLEFT1, "IT_LEFT1"],
                  [Blockly.Msg.HUMMERBOT_TRACKINGLEFTLEFT2, "IT_LEFT2"],
                ]),"TRACKINGSTATEOLD")
            this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
        this.setOutput(true, 'Boolean');
        this.setTooltip('');
          }
        };
				//设置下次偏离黑线前的循迹状态是
					Blockly.Blocks.hb_settrackingstateold = {
          init:function(){
          this.setColour("#00B1AC");
			   this.appendDummyInput("")
              .appendField(Blockly.Msg.HUMMERBOT_SETTRACKINGSTATEOLD)
              .appendField(new Blockly.FieldDropdown([
                  [Blockly.Msg.HUMMERBOT_TRACKINGLEFTRIGHT1, "IT_RIGHT1"],
                  [Blockly.Msg.HUMMERBOT_TRACKINGLEFTRIGHT2, "IT_RIGHT2"],
                  [Blockly.Msg.HUMMERBOT_TRACKINGLEFTLEFT1, "IT_LEFT1"],
                  [Blockly.Msg.HUMMERBOT_TRACKINGLEFTLEFT2, "IT_LEFT2"],
                  [Blockly.Msg.HUMMERBOT_TRACKINGNO, "0"],
                ]),"TRACKINGSTATEOLDSET")
      this.setPreviousStatement(true,null);
            this.setNextStatement(true,null);
          this.setTooltip('');
          }
        };

//火焰传感器模块引脚
 Blockly.Blocks.hb_firepin = {
          init:function(){
          this.setColour("#00B1AC");
          this.appendDummyInput("")
              .appendField(Blockly.Msg.HUMMERBOT_FIRE)
			   this.appendDummyInput("")
              .appendField(Blockly.Msg.HUMMERBOT_FIRELEFT)
              .appendField(new Blockly.FieldDropdown([
                ['0', "0"],
                  ['1', "1"],
                  ['2', "2"],
                  ['3', "3"],
                  ['4', "4"],
                  ['5', "5"],
                  ['6', "6"],
                  ['7', "7"],
                  ['8', "8"],
                  ['9', "9"],
                  ['10', "10"],
                  ['11', "11"],
                  ['12', "12"],
                  ['13', "13"],
                  ['A0', "A0"],
                  ['A1', "A1"],
                  ['A2', "A2"],
                  ['A3', "A3"],
                  ['A4', "A4"],
                  ['A5', "A5"],
                ]),"FIRELEFT")
				.appendField(Blockly.Msg.HUMMERBOT_FIRERIGHT)
              .appendField(new Blockly.FieldDropdown([
                ['0', "0"],
                  ['1', "1"],
                  ['2', "2"],
                  ['3', "3"],
                  ['4', "4"],
                  ['5', "5"],
                  ['6', "6"],
                  ['7', "7"],
                  ['8', "8"],
                  ['9', "9"],
                  ['10', "10"],
                  ['11', "11"],
                  ['12', "12"],
                  ['13', "13"],
                  ['A0', "A0"],
                  ['A1', "A1"],
                  ['A2', "A2"],
                  ['A3', "A3"],
                  ['A4', "A4"],
                  ['A5', "A5"],
                ]),"FIRERIGHT")
				 this.appendDummyInput("")
              .appendField(Blockly.Msg.HUMMERBOT_SOUND)
              .appendField(new Blockly.FieldDropdown([
                ['0', "0"],
                  ['1', "1"],
                  ['2', "2"],
                  ['3', "3"],
                  ['4', "4"],
                  ['5', "5"],
                  ['6', "6"],
                  ['7', "7"],
                  ['8', "8"],
                  ['9', "9"],
                  ['10', "10"],
                  ['11', "11"],
                  ['12', "12"],
                  ['13', "13"],
                  ['A0', "A0"],
                  ['A1', "A1"],
                  ['A2', "A2"],
                  ['A3', "A3"],
                  ['A4', "A4"],
                  ['A5', "A5"],
                ]),"SOUND")
          this.setPreviousStatement(true,null);
            this.setNextStatement(true,null);
          this.setTooltip('');
          }
        };
		//风扇引脚
		Blockly.Blocks.hb_fun = {
          init:function(){
          this.setColour("#00B1AC");
          this.appendDummyInput("")
              .appendField(Blockly.Msg.HUMMERBOT_FUN)
              .appendField(new Blockly.FieldDropdown([
                ['0', "0"],
                  ['1', "1"],
                  ['2', "2"],
                  ['3', "3"],
                  ['4', "4"],
                  ['5', "5"],
                  ['6', "6"],
                  ['7', "7"],
                  ['8', "8"],
                  ['9', "9"],
                  ['10', "10"],
                  ['11', "11"],
                  ['12', "12"],
                  ['13', "13"],
                  ['A0', "A0"],
                  ['A1', "A1"],
                  ['A2', "A2"],
                  ['A3', "A3"],
                  ['A4', "A4"],
                  ['A5', "A5"],
                ]),"FUN")
          this.setPreviousStatement(true,null);
            this.setNextStatement(true,null);
          this.setTooltip('');
          }
        };
		//左或右，有无火源
		Blockly.Blocks.hb_firefun = {
          init:function(){
          this.setColour("#00B1AC");
          this.appendDummyInput("")
              .appendField(new Blockly.FieldDropdown([
                  [Blockly.Msg.HUMMERBOT_FIREFUNLEFT, "A4"],
                  [Blockly.Msg.HUMMERBOT_FIREFUNRIGHT, "A3"],
                ]),"FIREFUNDIRECTION")
              .appendField(new Blockly.FieldDropdown([
                  [Blockly.Msg.HUMMERBOT_HAVEFIRE, "0"],
                  [Blockly.Msg.HUMMERBOT_HAVENOFIRE, "1"],
                ]),"ISFIRE")
          this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
        this.setOutput(true, 'Boolean');
        this.setTooltip('');
          }
        };
		//开关风扇
		Blockly.Blocks.hb_openfirefun
		= {
          init:function(){
          this.setColour("#00B1AC");
          this.appendDummyInput("")
              .appendField(Blockly.Msg.HUMMERBOT_OPENFUN)
              .appendField(new Blockly.FieldDropdown([
               [Blockly.Msg.HUMMERBOT_OPENFUNS, "1"],
                  [Blockly.Msg.HUMMERBOT_CLOSEFUNS, "0"],
                ]),"FUNSS")
          this.setPreviousStatement(true,null);
            this.setNextStatement(true,null);
          this.setTooltip('');
          }
        };
        //nrf初始化
        Blockly.Blocks.hb_nrfinit = {
            init: function () {
                this.setColour("#00B1AC");
                this.appendDummyInput("")
                    .appendField(Blockly.Msg.HUMMERBOT_NRFINIT)
                this.setPreviousStatement(true, null);
                this.setNextStatement(true, null);
                this.setTooltip('');
            }
        };

        //nrf数据已准备
        Blockly.Blocks.hb_nrfdataready = {
            init: function () {
                this.setColour("#00B1AC");
                this.appendDummyInput("")
                    .appendField(Blockly.Msg.HUMMERBOT_NRFDATAREADY)
                this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
                this.setOutput(true, 'Boolean');
                this.setTooltip('');
            }
        };
        //nrf接收数据
        Blockly.Blocks.hb_nrfgetdata = {
            init: function () {
                this.setColour("#00B1AC");
                this.appendDummyInput("")
                    .appendField(Blockly.Msg.HUMMERBOT_NRFGETDATA)
                // .appendField(new Blockly.FieldImage("../../media/panthertank/pt_bluetooth.png", 45, 38))
                //this.appendValueInput("nrfadd", String)
                //.appendField(new Blockly.FieldImage("../../media/MotorDriverBoard/hb_irtracking.png", 38, 32))
                this.setInputsInline(true);
                this.setPreviousStatement(true, null);
                this.setNextStatement(true, null);
                this.setTooltip('');
            }
        };
        //获取到nrf数据包？
        Blockly.Blocks.hb_nrfgetpackage = {
            init: function () {
                this.setColour("#00B1AC");
                this.appendDummyInput("")
                    .appendField(Blockly.Msg.HUMMERBOT_NRFGETPACKAGE)
                this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
                this.setOutput(true, 'Boolean');
                this.setTooltip('');
            }
        };
        //nrf数据类型是？下拉框
        Blockly.Blocks.hb_nrfdatafun = {
            init: function () {
                this.setColour("#00B1AC");
                this.appendDummyInput("")
                    .appendField(Blockly.Msg.HUMMERBOT_NRFDATAFUN)
        			 .appendField(new Blockly.FieldDropdown(
                   [
                       [Blockly.Msg.HUMMERBOT_NRFDIRECTION, "E_ROBOT_CONTROL_DIRECTION"],
                       [Blockly.Msg.HUMMERBOT_NRFSPEED, "E_ROBOT_CONTROL_SPEED"],
                   ]), "datafun")
                this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
                this.setOutput(true, 'Boolean');
                this.setTooltip('');
            }
        };
        //nrf获取的角度
        Blockly.Blocks.hb_nrfgetdegree = {
            init: function () {
                this.setColour("#00B1AC");
                this.appendDummyInput("")
                    .appendField(Blockly.Msg.HUMMERBOT_NRFGETDEGREE)
                    this.setPreviousStatement(true, null);
                    this.setNextStatement(true, null);
                    this.setTooltip('');
            }
        }
        //nrf获取的速度
        Blockly.Blocks.hb_nrfgetspeed = {
            init: function () {
                this.setColour("#00B1AC");
                this.appendDummyInput("")
                    .appendField(Blockly.Msg.HUMMERBOT_NRFGETSPEED)
                    this.setPreviousStatement(true, null);
                    this.setNextStatement(true, null);
                    this.setTooltip('');
            }
        };

*/











    return Blockly;
 }

module.exports = ArduinoUnoBlocks ;
